Free Support Forum - aspose.com

MSG saving issues

I have seen many posts on this and would like some information on what to do on this. I have a msg file that has 2 attachments that are msg format also. If I save those locally I cannot open them via outlook nor can I see the attachments via code.

Then I need to extract any attachments on those messages with no issues Recursive.

We need to be able to load an attachment as a MapiMessage with no issues and save that as an msg file locally.

This is a very large project and I need support on this asap.

Hello,

Thanks for considering Aspose.

1. Could you please attach your msg file for our debugging?

2. Do you need to extract the embedded msg file by aspose.network?

3. Could you provide more detailed information about your requirement?

Iret -

I cannot send you the message file for privacy concerns but this is a common issue with your library as we cannot save an attached msg message file.

Hi,


Please try the latest version of Aspose.Network for .NET from http://www.aspose.com/community/files/51/.net-components/aspose.network-for-.net/default.aspx. This should solve the problem of saving attached message files in eml or msg format. The sample code is given below:

// load msg file with attachments
MailMessage msg = MailMessage.Load(@“message-with-embedded-messages.msg”, MessageFormat.Msg);
// loop through all the attachments
foreach (Attachment att in msg.Attachments)
{
Console.WriteLine(“File Name: " + att.Name);
if (att.Name.Contains(”.eml") == true)
{
// save as eml
MemoryStream stream = new MemoryStream();
att.Save(stream);
stream.Position = 0;
// save as msg
MailMessage attMsg = MailMessage.Load(stream, MessageFormat.Eml);
attMsg.Save(att.Name.Replace(":", “”).Replace(".eml", “.msg”), MailMessageSaveType.OutlookMessageFormat);
Console.WriteLine(“Saved an email attachment.”);
}
else
{
att.Save(att.Name.Replace(":", “”));
Console.WriteLine(“Saved a regular attachment.”);
}
Console.WriteLine("======================================");
}