Aspose.Email GraphClient does not send attachement of mail while pure MS GraphClient does

Simple reproduction code using Aspose Email 23.5.1 (buggy) and plain Microsoft (working fine) :

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Aspose.Email.Clients;
using Aspose.Email.Clients.Graph;
using Aspose.Email.Mapi;
using Azure.Identity;
using Microsoft.Graph;
using Microsoft.Graph.Models;

namespace ConsoleAppAsposeMailOAuth
{
    internal class Program
    {
        static void Main(string[] args)
        {
            MSGraphAPI();

            AsposeGraphAPI();
        }

        public static void MSGraphAPI()
        {
            // The client credentials flow requires that you request the
            // /.default scope, and preconfigure your permissions on the
            // app registration in Azure. An administrator must grant consent
            // to those permissions beforehand.
            var scopes = new[] { "https://graph.microsoft.com/.default" };

            // Multi-tenant apps can use "common",
            // single-tenant apps must use the tenant ID from the Azure portal
            var tenantId = "XYZ";

            // Values from app registration
            var clientId = "XYZ";
            var clientSecret = "XYZ";

            // using Azure.Identity;
            var options = new TokenCredentialOptions
            {
                AuthorityHost = AzureAuthorityHosts.AzurePublicCloud
            };

            // https://learn.microsoft.com/dotnet/api/azure.identity.clientsecretcredential
            var clientSecretCredential = new ClientSecretCredential(
                tenantId, clientId, clientSecret, options);

            var graphClient = new GraphServiceClient(clientSecretCredential, scopes);

            byte[] contentBytes = System.IO.File.ReadAllBytes(".\\test.ps1");
            string contentType = "text/plain";

            var requestBody = new Microsoft.Graph.Users.Item.SendMail.SendMailPostRequestBody
            {
                Message = new Message
                {
                    Subject = "Meet for lunch?",
                    Body = new ItemBody
                    {
                        ContentType = BodyType.Text,
                        Content = "The new cafeteria is open.",
                    },
                    ToRecipients = new List<Recipient>
                    {
                        new Recipient
                        {
                            EmailAddress = new EmailAddress
                            {
                                Address = "firstname.lastname@mycompany.com",
                            },
                        },
                    },
                    HasAttachments = true,
                    Attachments = new List<Microsoft.Graph.Models.Attachment>
                    {
                        new FileAttachment
                        {
                            OdataType = "microsoft.graph.fileAttachment",
                            ContentBytes = contentBytes,
                            ContentType = contentType,
                            ContentId = "testing",
                            Name = "tesing.txt"
                        }
                    }
                },
                SaveToSentItems = false,
            };

            var task = Task.Run(async () => { await graphClient.Users["daemon@mycompany.com"].SendMail.PostAsync(requestBody); });
            task.Wait();
        }

        public static void AsposeGraphAPI()
        {
            var accessParams = new AccessParameters()
            {
                TenantId = "XYZ",
                ClientId = "XYZ",
                ClientSecret = "XYZ",
                UserId = "daemon@mycompany.com"
            };

            // prepare the message
            var msg2 = new Aspose.Email.MailMessage();
            msg2.Subject = "My MailMessage";
            msg2.Body = "Hi, it is my message";
            msg2.To.Add(new Aspose.Email.MailAddress("firstname.lastname@mycompany.com"));
            msg2.Attachments.Add(new Aspose.Email.Attachment(".\\test.ps1"));

            var options = new MapiConversionOptions(OutlookMessageFormat.Unicode);
            var msg = MapiMessage.FromMailMessage(msg2, options);

            var tokenProvider = new GraphTokenProvider(accessParams);

            using (var client = GraphClient.GetClient(tokenProvider, accessParams.TenantId))
            {
                client.Resource = ResourceType.Users;
                client.ResourceId = accessParams.UserId;

                try
                {
                    // send message
                    client.Send(msg);
                }
                catch(Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
        }
    }
}

Using Aspose Email is not sending attachement, when using plain MS is sending attachement, see screenshots :

image.png (15.2 KB)

Same problem for embedded elements (like embedded images)

@PBaelen
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): EMAILNET-41089

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Hello Margarita,
I’m not sure if issue is resolved already ?
Using 23.6 (which apparently is stated to solve EMAILNET-41089) with the code sample I provided , this catched exception occurs :

System.FormatException
  HResult=0x80131537
  Message=Date is not in valid format
  Source=Aspose.Email
  StackTrace:
   at #=zKpTUgnaqEMnJ9Vxy1lzbxeQIqbQo$4LvFUO4Vv4=.#=zcOBkkRk=(String #=zh_F_ECc=, TimeSpan& #=zGaM6LDPcnoBn)

stack :

Aspose.Email.dll!#=zKpTUgnaqEMnJ9Vxy1lzbxeQIqbQo$4LvFUO4Vv4=.#=zcOBkkRk=(string #=zh_F_ECc=, out System.TimeSpan #=zGaM6LDPcnoBn) Unknown
Aspose.Email.dll!#=zKpTUgnaqEMnJ9Vxy1lzbxeQIqbQo$4LvFUO4Vv4=.#=zAC64Yho=(string #=zh_F_ECc=, out System.DateTime #=zaszk5Zw=, out System.TimeSpan #=zGaM6LDPcnoBn) Unknown
Aspose.Email.dll!#=zaV3O7Hay6b8JzoO6Bxye23AT1HtMMJi_GvVe6L_80kTi.#=zXrM2xhlDSbZT(Aspose.Email.MailMessage #=zAbiMmBkOmaANFnRQjg==, Aspose.Email.Mapi.MapiMessage #=zGBRjuBUpXtc9) Unknown
Aspose.Email.dll!#=zaV3O7Hay6b8JzoO6Bxye23AT1HtMMJi_GvVe6L_80kTi.#=z$FYrsZlJAVbQtx6jBA==(Aspose.Email.Mapi.MapiMessage #=zRFNVs$Q=) Unknown
Aspose.Email.dll!Aspose.Email.Mapi.MapiMessage.ToMailMessage(Aspose.Email.Mapi.MailConversionOptions options) Unknown
Aspose.Email.dll!#=zSpsssChT$CQtvToGqvojnebD7kqoM8YLtpnOyvQ=.#=zjvWYgLpNb9y6() Unknown
Aspose.Email.dll!#=zoYOU4PRmajCrNekJ1YKm5KqyWKbuSxUecqZt2KMcdVPF<Aspose.Email.Mapi.MapiMessage>.#=zM$R2pRk=(string #=zCy4IVTw=) Unknown
Aspose.Email.dll!#=zoYOU4PRmajCrNekJ1YKm5KqyWKbuSxUecqZt2KMcdVPF<Aspose.Email.Mapi.MapiMessage>.#=zs9SffSQ=() Unknown
Aspose.Email.dll!#=zC0EK0mxGaSQl5ecHrJnB5A8hiib$kGXSTg==.Send(Aspose.Email.Mapi.MapiMessage #=zLC_qjcU=) Unknown
> ConsoleAppAsposeMailOAuth.exe!ConsoleAppAsposeMailOAuth.Program.MSGraphAPI() Line 142 C#
ConsoleAppAsposeMailOAuth.exe!ConsoleAppAsposeMailOAuth.Program.Main(string[] args) Line 19 C#

I receive the expected mail but still without attachement.

Meanwhile if I populate ClientSubmitTime and DeliveryTime with DateTime.Now instead of default value then there is no catched exception, also I receive expected mail but still without attachment.

Can you please advise ?

@PBaelen,

We’ll investigate your issue and give you feedback as soon as possible.

@PBaelen,

We have tested the issue on our side. The issue is not reproduced. Perhaps you’ve tested a different use case? Could you share a new code sample with us?

// stacktrace
ConsoleAppAsposeMailOAuth.Program.MSGraphAPI() Line 142

Could you check if Outlook has blocked access to an unsafe attachment.
test.ps1 attachment
1.png (10.0 KB)

test.txt attachment
2.png (10.9 KB)

In addition, in the last release, we added a new method for sending a message:

// Sends email message using MIME format
void SendAsMime(MapiMessage message)