I am trying to walk a folder structure full of MSG files and extract the meta data from each file. Some of the files may be encrypted so I won’t be able to get the body (which is fine).
How can I determine if the file is encrypted and if so still extract the from, cc, subject etc.?
I’m using MapiMessage to load the MSG files in my code:
MapiMessage msg = MapiMessage.FromFile(MSGFile);
Thanks
Hi Richard,
I guess I should have said it was s/mime encrypted. I opened the MSG file using MapiMessage, not MailMessage. I’m still learning the Aspose tools, do you have a code snippet which shows how to open the MSG file with a MailMessage object?
Thanks so much.
Hi Richard,
You can load a MSG file using MailMessage and then load MapiMessage from this MailMessage as well. Please have a look at the following code for your reference.
//Load the MSG file using MailMessage
MailMessage mailMsg = MailMessage.Load("SampleMsg.msg", MessageFormat.Msg);
//Initiate the MapiMessage from MailMessage
MapiMessage mapiMsg = MapiMessage.FromMailMessage(mailMsg);
You can also refer to the Programmers Guide section of online documentation to gain additional information related to Aspose.Email features and examples. Please feel free to contact us in case of any query/inquiry.
That’s way too easy!
So just to make sure I understand correctly. If the MSG file is s/mime encrypted the IsSigned property will be true and I will still be able to read the other metadata fields.
Thanks again.
One more quick question. Where is the EntryID property in the MailMessage object?
It looks like I need to create the MapiMessage from the MailMessage and then I can get at the Mapi properties via MapiMessage.Properties[MapiPropertyTag.PR_SENDER_ENTRYID]
correct? Or is there a direct way to get it from MailMessage?
I assume creating the MapiMessage will still work without throwing an exception if the MailMessage is mime encrypted (I don’t have any sample encrypted MSG files unfortunately, so debugging is a pain)
Hi Richard,
Hi Richard,
You wrote to us:
“So just to make sure I understand correctly. If the MSG file is s/mime encrypted the IsSigned property will be true and I will still be able to read the other metadata fields.”
I would like to share that AE uses S/MIME protocol for encrypting messages.
S/MIME provides two security services: digital signatures and message encryption. MailMessage.Encrypt encrypts and signs a message. That’s why the IsSigned flag is true. But this flag doesn’t signal that a message is definitely encrypted. As a message can be just signed but not encrypted. Now AE doesn’t have an exact method for defining whether a message is encrypted. IsSigned shows ‘true’ only for the following content-type values:
“application/pkcs7-mime”, “application/x-pkcs7-mime”, “multipart/signed”. But it doesn’t guarantee that a message is signed and encrypted at the same time.
For your reference see also the following info:
Please feel free to write us back if you have any other query in this regard.
Thanks so much for your help. I’m up and running. Great support!
Hi,