We are sorry for the inconvenience you are facing.
I would like to share with you that we got such exception in past as well due to various internal reasons that were then fixed by our development team in the follow up release. I would request you to please provide us with the EML files for the mentioned issues. We will provide these to our development team for further investigation and will try to provide solution as soon as possible.
I was able to reproduce the issues you mentioned using the latest version of Aspose.Email for .NET 2.2.0 at my end. I have logged these bugs in our issue tracking system for further investigation by our development team. We will update you here once we have the fix ready for the resolution of these issues, and appreciate your patience in this regard.
The bugs have been logged as NETWORKNET-33500 and NETWORKNET-33501 in our issue tracking system.
I am experience similar issues, running Aspose.Email for .NET v3.3.0, specifically “The specified content type is invalid”.
If I edit the eml file and change the content type from png to image/png and pdf to application/pdf respectively, the message loads fine.
I understand these may not be valid content types, however I would expect to be able to load the message as other mail clients do not have an issue with this example.
Aspose.Email provides facility to skip the validity checks during Load operation. Following sample code loads this message and saves the attachment PDF and inline image on disc.
MailMessage mail = MailMessage.Load(@“D:\Aspose\Invalid Content Type.eml”, FileCompatibilityMode.SkipValidityChecking); foreach (Attachment att in mail.Attachments) { if(att.ContentType.MediaType == “pdf/”) att.Save(att.Name + “pdf”); } foreach (LinkedResource res in mail.LinkedResources) { if (res.ContentType.MediaType == “png/”) res.Save(“Image.png”); }
Could you please give it a try and let us know the feedback?
I have tried different messages including the one having content type issues. However it is found that once the message is loaded (with or without FileCompatibilityMode), it can be saved to stream or disc without any error. Please feel free to write us back if you have any other query in this regard.
Except where this email is an embedded attachment within another MailMessage and I need to save this MailMessage in Outlook MSG format. If I don’t specify MessageFormat.Msg, the output defaults to eml which is not what I want. If I specify MessageFormat.Msg, I get an exception.
If you are loading a message (with another attachment message) and saving the attachment directly, it will always be saved as EML. This is the default behavior. However, you can use the following code sample to save the attachment MSG as Outlook MSG file.I have also attached a sample MSG here for your reference. Please give a try to the code sample and let us know your feedback.
Sample Code:
string dir = “EMAIL_496660\”;
MailMessage mailMsg = MailMessage.Load(dir + "message 1.msg");
Attachment att = mailMsg.Attachments[0];
MemoryStream ms = new MemoryStream();
att.Save(ms);
MailMessage mailMsg2 = MailMessage.Load(ms);
mailMsg2.Save(dir + "TestMsg.msg", MailMessageSaveType.OutlookMessageFormat);
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.