0 votes

I'm having an issue hopefully you would be able to help.

I am trying to read email subject.

I have an eml file. I open it via outlook. The initial subject is "ImageDownload".
Than I change its subject to "ImageTestDownload".
Than I save it as a new file with msg extension.
Than I am trying to open this msg file via MsgConverter passing path to file to constructor.
After that I create IMail object by converter's method CreateMessage.

The problem is that Imail object return me subject "ImageDownload". Not "ImageTestDownload".

If I open msg file in Outlook it shows the subject as "ImageTestDownload".

Limilabs Mail.dll version is 3.0.20007.1248

Link to GitHub repository

Eml and msg files are attached to console application project.

Looking forward to your feedback.

by (310 points)

1 Answer

+1 vote

The thing is, that this msg is a bit incorrect.

It contains a modified subject ("ImageTestDownload") in __substg1.0_0037001F however it also contains original headers:

X-Sender: kmita1996@gmail.com
X-Unsent: 1
Filing-Info: DestinationId=40883;FileAttachments=True;FileBody=True;SplitPdf=False
MIME-Version: 1.0
Date: 26 Mar 2020 15:25:59 +0300
Subject: ImageDownload
Content-Type: multipart/mixed;
 boundary=--boundary_9_5b5e3789-7ed2-40b4-b11c-0f8d5e102b9f

You can use Msg2IMailConfiguration.IgnoreHeaders to ignore headers:

string fileName = ImageTestDownload.msg";
using (MsgConverter converter = new MsgConverter(fileName))
{
    IMail email1 = converter.CreateMessage();  
    Assert.AreEqual("ImageDownload", email1.Subject);

    IMail email2 = converter.CreateMessage(
        new Msg2IMailConfiguration { IgnoreHeaders = true });
    Assert.AreEqual("ImageTestDownload", email2.Subject);
}
by (301k points)
Thanks! It works!
...