Problem in Attachments

hi, i have purchased a license for aspose.network.

I have a problem opening some emails, with pdf attachments.
The email are saved to disk with MS Outlook in MSG Format. The original email messages are sent by a Fax Server, for incoming fax calls.

The Fax Server, when it comes a fax call, it saves the pages in PDF forrmat, then it sends the PDF attached to an email.
The resulting email, is saved by a MAPI application in MSG format.
If I try to open that file with MSOutlook, everything is ok. There is a PDF attached, with the "image" of the FAX.
If I try to open that file with aspose.network, there are 2 PDF attached, with the same name. One is the PDF with the fax, and one is an empty attachment... and i'm not able to see inside it.

Can you help me?

Many thanks.
Best regards,
Andrea Puliti.

Hi Andrea,

Can you post a sample msg file here. I will test this and let you know about my findings.

thank you for the reply

ok. see the attached file.

EDIT: There are a problem with attachment size, too... the size is always 0, even if the message is not a fax.

Hi,

Please test the msg file using the code below. It seems Ok to me. The Attachment collection showed 1 attachment and successfully saved as pdf file.

MapiMessage msg = MapiMessage.FromFile(@“c:\temp\fax.msg”);

foreach (MapiAttachment att in msg.Attachments)

{

att.Save(@“c:\temp” + att.FileName);

}

Please also refer to http://www.aspose.com/documentation/utility-components/aspose.network-for-.net/load-from-a-microsoft-outlook-message-file.html for reading outlook msg files.

hi,
thank you for attention.
I cannot do that thing... That file, is an email, for me. When i open it, i don't know if it is a "Mapi originated email", or a "standard eml email message".

What can I do?

Best regards,
Andrea Puliti.

Hi,

If you are loading file from disk, you can read email in both eml and msg formats. Parse the filename and get the extention and call the overloaded function "FromFile" with respective parameters. See the code below for example.

string strExtention = "eml"; // parse the extention of the file

MessageFormat msgFormat = null;

if (strExtention == "msg")

msgFormat = MessageFormat.Msg; // msg format

else if (strExtention == "eml")

msgFormat = MessageFormat.Eml; // eml format

MailMessage msg = Aspose.Network.Mail.MailMessage.Load(@"c:\temp\fax.msg", msgFormat);

foreach (Attachment att in msg.Attachments)

{

att.Save(@"c:\temp\" + att.Name);

}

I know, but it's different from what you wrote:

MapiMessage msg = MapiMessage.FromFile(@"c:\temp\fax.msg");

foreach (MapiAttachment att in msg.Attachments)

{

att.Save(@"c:\temp\" + att.FileName);

}

If I do:

MailMessage msg = Aspose.Network.Mail.MailMessage.Load(@"c:\temp\fax.msg", MessageFormat.Msg);

foreach (Attachment att in msg.Attachments)

{

att.Save(@"c:\temp\" + att.Name);

}

i have the problem with attachments....

Hi,

Please check the attached dll file for the fix. Now, MailMessage class should read correct number of attachments.

ok, now it works fine…
thank you very much.

Andrea.