Setting DisplayName on MailAddress for From-property causes Outlook to prompt when sending mail

Hi

We are setiing the From property with both Address (test@mytest.tst) and DisplayName (MyTestName) on the MailAddress object.
When the email is opened in outlook and we try to send it Outlook prompts that it does not recognize “MyTestName”:

Prompt.png (7.0 KB)

The header of the msg file looks like this:
image.png (8.9 KB)

The mail is created from the memoryStream fed by the MailMessage object msg in this way:

msg.Save(memoryStream, MailMessageSaveType.OutlookMessageFormat);

Is this a bug in the mail that Aspose.EMail generates? Perhaps fixed in a newer version?
A bug in Outlook?
Something else i missed along the way?

Outlook version 2013, Aspose.Email for .Net version 3.8.0.0

@Krifa_delegate_jba,

We have tested this with the latest version of Aspose.Email for .NET 17.12 and Outlook 2016, and couldn’t hit an issue as you have reported. We noticed that you are using quite an older version of the API at your end. Please use this latest version and let us know your feedback.

OK - so first of all: Thank you for the swift response.

Secondly - I am sorry for the weeks it has been since I worked on this. We had to upgrade the license and another urgent task came along and needed to be prioritized.

Third and more important - I have upgraded to Aspose.Email version 17.12 and made the changes to the code that the upgraded assembly required (parameters regarding save-options and encoding types) and I still have the issue with both outlook 2013 and outlook 2016.

The piece of code that sets the sender is this:

            if (!string.IsNullOrEmpty(fraAdresse))
            {
                msg.From = fraAdresse;
            }
            if (!string.IsNullOrEmpty(afsenderNavn))
            {
                msg.From.DisplayName = afsenderNavn;
            }

And the piece of code that creates the stream is this:

            var msg = new MailMessage();
            ... (add sender, recepient, body etc)
            var memoryStream = new MemoryStream();
            msg.Save(memoryStream, SaveOptions.DefaultMsgUnicode);
            return memoryStream;

What have I done differently than the test you have performed?

@Krifa_delegate_jba,

We have used the latest version of Aspose.Email for .NET 18.1 and the following code sample which is similar to yours. It creates the message fine which when opened in Outlook 2016 is sent without any issue.

Sample Code

var msg = new MailMessage("sender@domain.com", "receiver@gmail.com", "Subject", "Body");
msg.From = new MailAddress("sender@domain.com");
msg.From.DisplayName = "MyTestName";
var ms = new MemoryStream();
msg.Save(ms, Aspose.Email.SaveOptions.DefaultMsgUnicode);
ms.Position = 0;
using (FileStream file = new FileStream("file.msg", FileMode.Create, System.IO.FileAccess.Write))
{
    byte[] bytes = new byte[ms.Length];
    ms.Read(bytes, 0, (int)ms.Length);
    file.Write(bytes, 0, bytes.Length);
    ms.Close();
}

Thank you again. I apologise deeply that I have troubled you with this.

The good news: Everything works just fine from an aspose-point of view.

The bad news (for me and my client): The trouble is due to a third party web-application that “my” application is an extension to. This application takes my memorystream and does “something” to it before it is streamed to the browser (which makes no sense at all cry)

Well thumbs up to Aspose - both for the products and the support!

1 Like

@Krifa_delegate_jba,

Thank you for the feedback and wish you good luck for your task. Please feel free to write us back if you have any other query related to Aspose.Email.