Attachment extension

Hello All,


I was hoping that someone would be able to help me, i am trialing the aspose.email .net module.

I am trying to extract attachments from a PST, I can get them fine, but I require the extension type to be recorded in our database.

Dim attachment As MapiAttachment
For Each attachment In message.Attachments
MsgBox(attachment.Extension) <— displays a black msgbox
Next

The above code is a test to check if I could get the extension, but it doesn’t work.

Is there any working examples out there?

Glen

My current workaround is MsgBox(Mid(IO.Path.GetExtension(attachment.FileName), 2))


but it isn’t a great way to do it.

Glen

Hi Glen,

Thank you for writing to Aspose support team.

I would like to share the working details of attachment extension in this case. MapiMessage takes the Extension property value from the
PR_ATTACH_EXTENSION mapi property. If this property is absent, the Extension
property gets nothing. You can use the following sample code to determine if this property exists or not. Please let us know if we can be of any additional help to you in this regard.

Sample Code:


MapiMessage mapi = MapiMessage.FromMailMessage(“AEMsgWithAtt.msg”);


foreach (MapiAttachment att in mapi.Attachments)

{

if (att.Properties.Contains(MapiPropertyTag.PR_ATTACH_EXTENSION))

Console.WriteLine(att.Extension);

}