Issue with sending .msg files with large attachments in Aspose.Email 26.5 (not with 26.4)

I have an issue with Aspose.Email 26.5.0 when sending emails attachments over 5mb from emails created in code and saved as an .msg. An email created manually using Outlook 365 works with both versions of the Aspose.Email library.

Using the example application below with Aspose.Email 26.5.0 I get the following error on this line client.Send(msg2)

This exception was originally thrown at this call stack:
    Aspose.Email.MailAddress.MailAddress(string, string, System.Text.Encoding, bool)
    Aspose.Email.MailAddress.MailAddress(string, string, System.Text.Encoding)
    Aspose.Email.MailAddress.MailAddress(string, string)
    #=z0Mqsa60CAzmO8Bb_blCsxMleL4ZRdu$uxhd7aIo=.#=z$$wJOtz9tl5E()
    #=zvvpqhZhYT_mF2YKO56aYRIkjVYFYPKYdlmpBKYE=.#=zcn5KtgR8OZ8C(string)
    #=zU5WIJGinK8bdL4ecTKTHLWWYzmMIaiKIx6p08Rvc5zxk<#=zUpCgX18=>.#=zjYysPQM=(System.Text.StringBuilder, System.Net.HttpWebResponse)
    #=zU5WIJGinK8bdL4ecTKTHLWWYzmMIaiKIx6p08Rvc5zxk<#=zUpCgX18=>.#=zvMsU4K8=()

When I use Aspose.Email 26.4.0 this error doesn’t occur.

Public Class AccessParameters
   Public Property TenantId As String
   Public Property ClientId As String
   Public Property ClientSecret As String
   Public Property UserId As String
   Public ReadOnly Property Authority As Uri
      Get
         Return New Uri($"https://login.microsoftonline.com/e16c1971-6a79-4862-99bc-8c5546b2b3eb")
      End Get
   End Property
   Public ReadOnly Property ApiUrl As String
      Get
         Return "https://graph.microsoft.com/.default"
      End Get
   End Property
End Class
Imports Microsoft.Identity.Client
Imports Microsoft.Identity.Web
Imports Aspose.Email.Clients
Imports Aspose.Email.Clients.Graph
Imports System
Imports System.Threading.Tasks

Public Class GraphTokenProvider
   Implements Aspose.Email.Clients.ITokenProvider, IDisposable

   Private ReadOnly _app As IConfidentialClientApplication
   Private ReadOnly _scopes As String()
   Private _token As String

   Public Sub New(accessParams As AccessParameters)
      _app = ConfidentialClientApplicationBuilder.Create(accessParams.ClientId) _
          .WithClientSecret(accessParams.ClientSecret) _
          .WithAuthority(accessParams.Authority) _
          .Build()

      _app.AddInMemoryTokenCache()
      _scopes = New String() {accessParams.ApiUrl}
   End Sub

   Public Sub Dispose() Implements IDisposable.Dispose
      Throw New NotImplementedException()
   End Sub

   Public Function GetAccessToken() As Aspose.Email.Clients.OAuthToken Implements ITokenProvider.GetAccessToken
      Return GetAccessToken(False)
   End Function

   Public Function GetAccessToken(ignoreExistingToken As Boolean) As Aspose.Email.Clients.OAuthToken Implements ITokenProvider.GetAccessToken
      If Not ignoreExistingToken AndAlso _token IsNot Nothing Then
         Return New OAuthToken(_token)
      End If

      _token = GetAccessTokenAsync().GetAwaiter().GetResult()
      Return New OAuthToken(_token)
   End Function

   Private Async Function GetAccessTokenAsync() As Task(Of String)
      Dim result As AuthenticationResult = Nothing

      Try
         result = Await _app.AcquireTokenForClient(_scopes).ExecuteAsync()
         Console.WriteLine("Token acquired")
      Catch ex As MsalServiceException When ex.Message.Contains("AADSTS70011")
         Console.WriteLine("Scope provided is not supported")
         result = Nothing
      Catch ex As Exception
         Console.WriteLine("XXXX")
         result = Nothing
      End Try

      If result Is Nothing Then Return Nothing
      _token = result.AccessToken
      Return result.AccessToken
   End Function

End Class
Imports System
Imports System.Security.AccessControl
Imports Aspose.Email
Imports Aspose.Email.Clients.Graph

Module Program
    Sub Main(args As String())
      Dim accessParams As New AccessParameters() With {
        .TenantId = "<TenantID>",
        .ClientId = "<ClientID>",
        .ClientSecret = "<ClientSecret>",
        .UserId = "<MailboxID>"
    }
      Dim lic As New Aspose.Email.License
      lic.SetLicense("G:\F2F\License\Aspose.Total.lic")
      Dim tokenProvider = New GraphTokenProvider(accessParams)
      Using client = GraphClient.GetClient(tokenProvider, accessParams.TenantId)
         client.Resource = Aspose.Email.Clients.Graph.ResourceType.Users
         client.ResourceId = accessParams.UserId
         'client.EndPoint = "https://login.microsoftonline.com/e16c1971-6a79-4862-99bc-8c5546b2b3eb"
         client.EndPoint = "https://graph.microsoft.com"

         Dim msgLoadOptions As MsgLoadOptions = New MsgLoadOptions()
         msgLoadOptions.PreserveEmbeddedMessageFormat = True

        Dim msg1 As MailMessage = MailMessage.Load("C:\Temp\Manually created with 22mb picture.msg", msgLoadOptions)
         client.Send(msg1)

         Dim msg2 As MailMessage = MailMessage.Load("C:\Temp\Generated from Code picture.msg", msgLoadOptions)
         client.Send(msg2)
      End Using
   End Sub
End Module

Link to the .msg files used in the example.

(https://face2facecontact-my.sharepoint.com/:f:/g/personal/i_tyrrell_face2facecontact_co_uk/IgCFITr4RVZ4QICtgXVp08uUAZQxGLfJ96rdennZV_38aog?e=wV4l7t)

Please can you advise?

Regards
Ian Tyrrell

Hello @IanTyrrell,

Thank you for the detailed report. We will review this case and update you as soon as we have more information.

Hi @IanTyrrell
This bug has been fixed, and the fix will be available in the upcoming 26.6 release. For now, you can use workaround:

Dim msg2 As MailMessage = MailMessage.Load("C:\Temp\Generated from Code picture.msg", msgLoadOptions)
msg2.Sender = Nothing
client.Send(msg2)