We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Saving MSG file loses properties from the Email Message

I am attempting to generate a MSG file from scratch, to generate a template email for the user, using the Aspose.Network library (version 4.7.0.3), and it is partially working - a MSG file is generated, and will open within Outlook, however a number of properties are modified when Outlook reads the generated MSG file back.

  1. The Priority of the Message is lost completely
  2. The Attachments are modified to be mapped as Inline within the opened attachment.
I have also tried using the NormalMessageMailMessageInterpretor class, but calling save using this class generates a MailException with the following message

"Recent Aspose.Network does not support saving to Msg format file.“

The code being used for the generation of the email is as follows:

Aspose.Network.License newLicence = new Aspose.Network.License();
newLicence.SetLicense(@”");

// Create a Mail Message
Aspose.Network.Mail.MailMessage newMessage = new Aspose.Network.Mail.MailMessage();
newMessage.To.Add("to@sample.com");
newMessage.TextBody = “Sample Text”;
newMessage.Subject = “Sample Subject”;

// Set the priority
newMessage.Priority = Aspose.Network.Mail.MailPriority.High;

// Add an Attachment
Aspose.Network.Mail.Attachment attachmentToAdd = new Aspose.Network.Mail.Attachment(@".\testattachment.txt");

attachmentToAdd.ContentDisposition.Inline = false;
attachmentToAdd.ContentDisposition.DispositionType = System.Net.Mime.DispositionTypeNames.Attachment;

newMessage.AddAttachment(attachmentToAdd);

// Now save this message as a .MSG file
Aspose.Network.Outlook.MapiMessage mapiMessage = Aspose.Network.Outlook.MapiMessage.FromMailMessage(newMessage);

// Set the Unsent Flag
mapiMessage.SetMessageFlags(Aspose.Network.Outlook.MapiMessageFlags.MSGFLAG_UNSENT);
mapiMessage.SetStringPropertyValue(Aspose.Network.Outlook.MapiPropertyTag.PR_SENDER_EMAIL_ADDRESS, “”);
mapiMessage.SetStringPropertyValue(Aspose.Network.Outlook.MapiPropertyTag.PR_SENDER_NAME, “”);

// Generates a msg file without Priority or Attachment within the Inline
mapiMessage.Save(“outputmessage.msg”);


// Throws a Message Exception
Aspose.Network.Outlook.NormalMessageMailMessageInterpretor messageInterpreter = new Aspose.Network.Outlook.NormalMessageMailMessageInterpretor();
messageInterpreter.Save(mapiMessage, new FileStream(@".\outputmessage2.msg", FileMode.Create), Aspose.Network.Mail.MessageFormat.Msg);

Hi,

1. Please use MailMessage.Save(filename, MessageFormat.Msg) to save a mailmessage instance to msg file. As code sample:

Aspose.Network.License newLicence = new Aspose.Network.License();
newLicence.SetLicense(@"");

// Create a Mail Message
Aspose.Network.Mail.MailMessage newMessage = new Aspose.Network.Mail.MailMessage();
newMessage.To.Add("to@sample.com");
newMessage.TextBody = "Sample Text";
newMessage.Subject = "Sample Subject";

// Set the priority
newMessage.Priority = Aspose.Network.Mail.MailPriority.High;

// Add an Attachment
Aspose.Network.Mail.Attachment attachmentToAdd = new Aspose.Network.Mail.Attachment(@".\testattachment.txt");

attachmentToAdd.ContentDisposition.Inline = false;
attachmentToAdd.ContentDisposition.DispositionType = System.Net.Mime.DispositionTypeNames.Attachment;

newMessage.AddAttachment(attachmentToAdd);

newMessage.Save("message.msg", MessageFormat.Msg);//save to msg

2. For the priority issue, we are now working on it. I will get back to you ASAP.

Thanks,

I have tried using the suggested method

newMessage.Save(“outputmessage3.msg”, Aspose.Network.Mail.MessageFormat.Msg);

However the MSG file generated now says “Internet Message - sender and content cannot be verified”. In addition the Importance and attachment are still broken. This is the same as when I saved the file as .EML as an experiment.

So this method seems worse than the method I was using before.

Peter

From the silence can I take it that the control does not support the creation of a .MSG file from a MailMessage ?

If so, do you have any suggestions of a way of generating a .MSG file without the properties becoming lost / modified ?

Thanks.

Peter

Hi Peter,

Our developer is working this, including priority and attachment issues. Could you please provide your testing eml files for our test? I will get back to you ASAP.

Thanks,

Attached are the MSG files generated by the code above, in a Zip

Outputmessage3.msg is generated by

newMessage.Save(“outputmessage3.msg”, Aspose.Network.Mail.MessageFormat.Msg);

Outputmessage.msg is generated by

mapiMessage.Save(“outputmessage.msg”);

Hi Peter,

Thanks for your help.

I will get back to you ASAP.

Any progress on a fix for this problem yet ?


From the silence I will take is as read that this won’t be fixed.

As this functionality was the entire reason we bought the control, this is somewhat disappointing.

Hi,

We are still working on this issue. But it is not yet resolved. I will keep you updated when we fix it.

I am encountering the same problem when saving attachments of email that are themselves email.


I started a thread about it (though as of this writing no one has responded)

http://www.aspose.com/community/forums/196812/outlook-error-when-saving-msg-attachments-using-mapiattachment/showthread.aspx#196812

I’m interested if you find a solution.

Thanks

P.S. By “same” I mean that after I get these attachments and determine they are email I am running this bit of code below. I get the same “sender and content cannot be verified” message in the MSG.

Aspose.Network.Mail.MailMessage msgAtt = Aspose.Network.Mail.MailMessage.Load(emlPath, Aspose.Network.Mail.MessageFormat.Eml);
msgAtt.Save(emlPath.Replace(".eml", “.msg”), Aspose.Network.Mail.MessageFormat.Msg);

This DLL might have the answer.


<a href="https://forum.aspose.com/t/44831

Well it’s now been over a month without hearing any further updates. I am going to recommend that we stop using your control, as it does not seem to do what we were lead to beleive it does i.e. Allow for the Creation of MSG files without Outlook.


The beta dll posted at <a href=“https://forum.aspose.com/t/44831 solves two bugs.

  1. Mail priority works correct
  2. "inetnet message - sender and content cannot be verified” message does not come anymore.
We are still working on the attachments issue. It is taking time to fix due to the complexity of the msg format.

Hi there,

i've the same problem with the latest dll of Aspose.Network 5....

This problem is fixed ? actually i'm working without license and

i'm deciding to buy the license. Is there a solution ?

thanks

alle

Hi Alle,

Thanks for considering Aspose.

All the mentioned issues were fixed and does not occur with Aspose.Network 5.3. The issues are:

  1. Priority is not saved
  2. Attachment comes in the body of the message
  3. A message is displayed on top of the msg file "Internet message - content not verified"
You can also verify these without the license file.