We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Issue with loading headers from EML file

I am using the latest DLL v1.4 and use the code below to retrieve headers from EML file. It return me exception.


Aspose.Email.Mail.MailMessage mail = Aspose.Email.Mail.MailMessage.Load(file, Aspose.Email.Mail.MessageFormat.Eml);

foreach (MimeHeader head in mail.Headers)
{
listBox1.Items.Add(string.Format("{0}: {1}", head.Name, head.RawContent));
}

Exception:
System.InvalidCastException was unhandled
Message=Unable to cast object of type ‘System.String’ to type ‘Aspose.Email.Mime.MimeHeader’.

I did a search in the forum and it appear same issue happened with IMAP but it was fixed in v1.4 but it doesn’t seems to be here.

Hi,


Thank you for your interest in Aspose products.

There are strings that hold header information instead of MimeHeader. That’s why an exception will be thrown. Please use strings instead. Check the below source code for your reference,

C#

Aspose.Email.Mail.MailMessage mail = Aspose.Email.Mail.MailMessage.Load(file);
foreach (string key in mail.Headers.AllKeys)
{
Console.WriteLine(key + ": " + mail.Headers.Get(key));
}

Thanks. Got that covered.


Another question regarding the attachment object. It always return attachment name in license.txt. Any idea?

Hi,


I guess you are using the Aspose.Email component in Evaluation Mode. Please check the related article for your reference.

You may also get a temporary license, if you want to use the component at it’s full capacity. To get a temporary license, please follow the instruction provided on this page.

Please feel free to write back.

I’ve got full license. It appears I didn’t set the license in code.


Right after I did that, the attachment count return 0 instead of 1, which the EML suppose to have one PDF attachment. How can I troubleshoot this?

Hi,


Please share your EML for our review. You can not attach an EML file directly. Please zip it and attach with your reply.

Thanks

here you go.

Hi,


Thank you for providing the sample.

I can reproduce this problem with Aspose.Email for .NET v1.4.0. The attached EML file has a PDF document as attachment. When loaded in an instance of MailMessage, the AttachmentCollection count is always 0. For correction purposes I have logged a ticket (NETWORKNET-33177) and linked this thread to it. Once a fix is available, you will be notified via this thread.

We are sorry for your inconvenience.

The issues you have found earlier (filed as NETWORKNET-33177) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.