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

Free Support Forum - aspose.com

Getting attachment named mapi property while processing TNEF messages by means of MailMessage class

Hi,

In my scenario I use MailMessage class to process messages from Exchange Server, which are TNEF messages (EML message with one MIME part - application/ms-tnef; name=“winmail.dat”).

After processing I save message in the same format by means of PreserveTnefAttachments flag.

But recently I got additional task - I must analyze attachment MAPI properties to find there special named property. It is easy with MapiMessage, but still I need use MailMessage in order to save message in the original format.

Aspose do has MailMessageInterpretor and we can convert MapiMessage to MailMesage, but after saving converted message it does NOT have winmail.dat MIME part, it will be multipart/mixed - original format is lost.

MailMessage has LinkedResources collection, which includes inline images (like signature) etc. MapiMessage has only one collection for all attachments (Attachments). So is there any means to get definite correspondence between attachments in MapiMessage.Attachments and MailMessage.Attachments collections?

If so, I will be able to get attachment’s named property by MapiMessage, but use MailMessage.Attachments to process email and save in the original format.

Or there may be another approach…

Best regards,

Alex Sloma

Hi Alex,


Thank you for contacting Aspose support team.

We are analyzing the requirement and would like to request you to send us the some sample EML file along with information about some special named property. It will help us to inspect the problem and provide assistance as soon as possible.

Here you are.

I attached project with sample TNEF EML message.

Test email has to attachments. Each of them has named property called “CustomAttGuid” containing string representation of guid.

My task is to get this named property value, process attachments according to retrieved guid (lets think I need to replace attachments if guid has certain value) and save message to the original format by means of PreserveTnefAttachments flag.

In sample project I:

  1. First I get attachment’s named property by means of TnefReader (see GetNamedPropertyByTnefReader method) in order to demonstrate that named property exists and its name is “CustomAttGuid”.

  2. Then I try to get the same result by means of Aspose.Email (see GetNamedPropertyByAspose method). And here I get first issue:

Aspose puts named properties in one collection with other attachment properties - Attachment.Properties. To determine whether it is named property I use the fact, that named property's identifier must be in following range 0x8000 - 0xFFFE. But there is no way to get the actual property name, because PropertyTagName is empty. That is why I have to iterate over all named property and try parse guid from its value - it is not good way, because we may get wrong value if there are more than one named property with guids.

Anyway I got named property’s value.


  1. Replace attachment if named property’s value is SOME_GUID.

  2. Save message to file in original format. And here is where the main issue appears:

I must use MailMessage and PreserveTnefAttachments flag to save message. But I used MapiMessage to replace attachment, because MapiMessage was used to get named property.

There is no reflection between attachments of MailMessage and MapiMessage, because MailMessage has LinkedResources collection, which includes inline images etc.

So is there any means to get definite correspondence between attachments in MapiMessage.Attachments and MailMessage.Attachments collections?



Best regards,
Alex Shloma

Hi Alex,


Please spare us little time as we are analyzing this issue and we are sorry for the inconvenience caused to you in this regard.

Hi, Kashif Iqbal.


Thanks for a quick reply. Looking forward to sharing your findings.

Best regards,
Alex Shloma

Hi Alex,


I have analyzed your sample project and requirements but could not found any useful information/link for these. I have requested development team’s feedback in this regard for appropriate information and will update you here as soon as there is some update available in this regard. We appreciate your patience in this regard.

Hi Alex,


We have discussed the issue and observed that if MapiMessage is created from MailMessage, the attachments in MapiMessage has same order as in the source MailMessage.

Regarding the second issue of searching the MapiProperty by name, I have logged a ticket id:NETWORKNET-34381 in our issue tracking system. Development team will look into it and will provide their feedback. I will write back here on the thread, as soon as some update is received in this regard.

Please feel free to write us back if you have any other query related to Aspose.Email.

The issues you have found earlier (filed as NETWORKNET-34381) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

I tested Aspose.Email 4.3.0.0. Works perfectly.


Good job.

Thanks, Alex Shloma

Hi Alex,


Thank you for providing the feedback. Please feel free to write to us in case you have any additional query/inquiry related to Aspose.Email.