Attachments convert from MSG to EML


Hello,

I'm using .NET 4.0 and Aspose.Email.dll 3.3.0.0.
If the attachment of an email is another email (file: attachment.msg) and it's sent in RTF format using Outlook 2010, when Aspose fetches the message (client.FetchMessage(sequence_number)) the attachment will show up as "attachment.eml". Aspose automatically converts it from .msg to .eml. Is there a reason for this or it's a bug in Aspose.Email.dll ?

Thank you

Hi Corneliu,

Thank you for contacting us regarding your query.

This is an expected behavior. MailMessage class treats all the Attachment messages (.msg) as EML and that is why you are seeing such behavior. In case you need to convert the attachment message back to MSG, you can get it in MailMessage class and save it in MSG format using the following code sample:

Sample Code:

MailMessage msg = MailMessage.Load("Sample.eml", MessageFormat.Eml);
Attachment att = msg.Attachments[0];

if (att.ContentType.MediaType == "message/rfc822")
{
    MemoryStream ms = new MemoryStream();
    att.Save(ms);

    MailMessage attMsg = MailMessage.Load(ms);
    attMsg.Save("AttachmentMsg.msg", MailMessageSaveType.OutlookMessageFormatUnicode);
}

Hello Kashif,

Not all the attachments that are .msg get converted to .eml.
If I send an email using Outlook 2010 and I add an attachment "attachment.msg" which has the extension ".msg". Then I connect to that mailbox and do a fetch on the message using client.FetchMessage(sequence_number) (POP3 and IMAP behave the same), then the attachment remains in ".msg" format, it doesn't get converted.
The attachments with extension ".msg" get converted to ".eml" only if I send the email in RTF format (using Outlook). Also, when sending an email in RTF format using Outlook, sometimes the attachments will end up without an extension. message.Attachments[0].Name will return just the file name without the extension
So the MailMessage class is not consistent with the attachments. If it was the standard to convert ALL the attachments from .msg to .eml, I would understand. But it doesn't convert all of them. Also, we're trying to keep the attachments in their original format. If they are .eml, we want to save them as .eml. If they are .msg, we want them as .msg

Hi Corneliu,


Thank you for the detailed feedback.

Could you please provide us some sample message files that we could use to observe the other issue as well? This will help us investigate the issue in more details and discuss this behavior with development team for further elaboration. We appreciate your cooperation in this regard.


Kashif,

I attached a file called "message.txt". You'll have to manually change its extension to ".msg" (when I tried to upload the file "message.msg" it didn't allow me for the proprietary reason? something like that)

I'll give you a bit of a background about this issue.
We created a mailbox dedicated to a specific purpose. We're going to receive email messages there, and some emails will have attachments. We'll save all the emails in ".eml" format and we want to save all the attachments in their original format (if they are .txt, .msg, .png, etc, we want to keep them that way).
In the scenario below, Aspose will automatically convert the ".msg" attachment to ".eml".

1. Open Outlook
2. Send "New E-mail"
3. Receiver, subject, body - anything in them
4. Drag & drop an email (I have it on my desktop and its called "quick test.msg") to the new email.
5. Click on the "Format Text" option at the top
6. Select "Rich Text" option in the "Format" group.
7. Send the email

We created a connection using Aspose (POP3 with SSL but it doesn't matter if it's POP3 or IMAP) to the mailbox that received the email.
Using Aspose we tried to download that email that we just received (it's the only email in the mailbox)
After fetching the email using the FetchMessage() method, the attachment name became "quick test.eml" instead of "quick test.msg". Now, because we created this test we do know the email was originally sent as ".msg". But the emails could come from other people and we don't know if they sent them as ".msg" or ".eml". That's why we want to keep their original format and it's impossible for us to know how the email was sent.
The file attached is the email I tested this with. Please remember that if you load the message from the file, it's different than how it's originally downloaded. In the case when downloaded, I explained above what happens. In the case when loaded from the file, the attachment name won't even have an extension. The attachment name will be "quick test" and that's it. I understand that we could get the format from ContentType.MediaType, but that doesn't actually tells us if it was originally ".eml" or ".msg". I don't think this is actually normal behavior.
I think the best way for you to test this is follow the steps above. If you try to load the email from the file I attached, it won't behave the same.
Also, if you follow the exact steps as above but NOT format the email as "Rich Text", the email will be downloaded successfully as ".msg" as it was originally sent. My opinion is that Aspose has a bug when handling emails sent in "Rich Text Format".
Thank you for your assistance on this one

Hi Corneliu,


Thank you for providing the details. We are investigating this issue further with multiple test cases and would share our feedback here in this regard soon. Your patience until then is highly appreciated.


Thanks Kashif. Let me know if you need more information about this issue or if development doesn't fully understand the problem, and I will try to explain it again.
Hi Corneliu,

We have discussed the issue with the developers and have logged it in our issue tracking system for detailed analysis as ID:NETWORKNET-34152. Development team will look into it and once we have any information regarding the resolution of this issue, we'll update you here via this thread.

If you have any other query/inquiry regarding Aspose.Email, please feel free to post to us. We'll try to assist you further as soon as possible.

Hi Corneliu,


We are sorry for not updating you about the status of this issue.

We have investigated this issue at our end and found that Aspose.Email does nothing other than fetching the email messages from the server in this case and present its information as available. In this case, after receiving all messages, all attachments are represented in eml format, and hence differentiating them is not necessary here. Also, please note that the attachment with mediaType = message/rfc822 can’t be represented as MSG but only in EML. Please let us know if we can be of any additional help to you in this regard.