+1 vote
by (170 points)


I am testing out the Pop3 Mail component to see if we want to replace our existing Pop3 Mail component. Our current component locks up after a while and is not robust enough for our use.

Our process is as follows:

  1. Emails are journaled to a specific pop3 email account as an attachement.
  2. I developed a service that will monitor the account for new emails and verify that the attachment is a mail message by checking the attachements DisplayName.
  3. attachement is saved to a memorystream and reloaded as another MailMessage, which is then processed into the database.

When I call the MailMessage.Load(stream) I get the following error message: Unable to parse mail message, headers end with an invalid line.

If I save the attachment as a file with the extension .eml and call MailMessage.Load with the filepath it loads fine.

Could you please let me know if there is a known issue with loading a memorystream? I'd prefer to not save the files to the disk as this process will operate on 2000 - 3000 emails daily. This issue is repeatable on every email I tried to load from a stream.


Don Tompkins

Applies to: Rebex Secure Mail

1 Answer

+1 vote
by (67.2k points)
Best answer

This error typically arises when the stream pointer is at the End of stream (so reading from the stream returns nothing).

Please ensure the stream.Position = 0 before you call the mail.Load(stream) method.