I was trying to save an attachement from my msg file but im getting an error. i thought it is posible since other controls can do that aswel. the error is:
" Conversion from string “List.xls” to type ‘Integer’ is not valid."
and the code that im trying to execute is:
Dim msg As MapiMessage = MapiMessage.FromFile(D:\test.msg)
It seems that you are using an older version of Aspose.Email for .NET component, because I couldn’t find Item member in Aspose.Email.Outlook.MapiAttachmentCollection class. Please check the below source code with Aspose.Email for .NET v1.3.0.
VB.NET
Dim message = Aspose.Email.Outlook.MapiMessage.FromFile(“C:\temp\message.msg”)
Dim attachments = message.Attachments
attachments(0).Save(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + attachments(0).LongFileName)
instead of Attchment(0).save(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + attachments(0).LongFileName)
can we replace 0 with the name of the attachment? that is what im trying to accomplish, so idont have to loop to all the attchment to get the file name.
I do not think you can pass a string (attachment name) instead of an integer index value. MapiMessage.Attachments is a collection of type MapiAttachment and you can access the indexed value by passing the integer only.