Unique ID for Attachments in MSG Files (where multiple attachments have the same name)

Using Aspose.Email, I have written the code for a web page that parses a MSG email, displays the header and body information and then loops through each attachment in the MSG file and displays the attachment name. I then have this name hyperlinked to another page which is supposed to open the email and the attachement and write the binary attachment data out to the browser via the Response.OutputStream.

The problem is that in an email, you can have multiple attachements all named exactly the same, and therefore, I can't use the attachment.name property as a unique value to pass to the second page. I tried using attachment.ContentID, but that is a GUID that appears to change everytime that the MSG file is opened. How can I get a unique identifier for the attachment that I can use to open it?

Hi,


Thank you for your interest in Aspose products.

I have recorded an investigative ticket for your said issue. The Ticket Id for your reference is 31351. As soon as we receive any updates we will post it here.

Meanwhile, you can implement your own custom logic to identify all such attachments by renaming the attachment names. Like Chrome does when downloading the files with same file names. It appends a numeric at the end of the file name. You can do the same with in your AttachmentCollection by removing all attachments that have exactly the same file names and adding them back after renaming. Check technical article on How to add and Save attachments.

It’s a viable workaround for your scenario. Please feel free to write back.

Babar, thanks for the information but that won’t for us. The MSG files are on read-only media and we are unable to modify the original document. Please let me know what your engineering team comes up with.

Hi,


You can uniquely identify the attachments having same file names by using PT_ATTACH_NUM property like as below,

msg.Attachments[i].GetPropertyInt32(MapiPropertyTag.PR_ATTACH_NUM)

There is no GetPropertyInt32 method for the Attachment object…?

Hi,


I apologize for my previous confusing statement.

Your required feature will be available in next release (v1.1) of Aspose.Email for .NET. Once new release is available for public use, you will be able to uniquely identify individual attachment as suggested in my previous reply.

New release will be available for you in first or second quarter of the next month.

Again, I deeply regret any inconvenience caused.