MailMessage.Sender

Hi,

While extracting messages from POP3 or from PST files,
I cannot see the sender details.

I’m using for POP3 :
MailMessage message = client.FetchMessage(i);

and for PST :
MapiMessage mapiMsg = personalStorage.ExtractMessage(messageInfo);
MailMessageInterpretor mi = MailMessageInterpretorFactory.Instance.GetIntepretor(mapiMsg.MessageClass);
MailMessage message = mi.Interpret(mapiMsg);

In both cases,
message.Sender.Address is null
and
message.Sender.DisplayName is null

for all mails extracted.

I would appreciate knowing if there is another way to get the sender’s mail and name ?


with regards,
Daniel.

Hi Daniel,

We are sorry for a delayed response.

After an initial investigation using sample messages at my end, I was able to observe the issue as you mentioned. However, in all these messages, sender information was missing, though “From” information is available. Please note that Sender information can be different from the “From” information as explained HERE. In order to get the mail address and name from the “From” field, you can try the following sample code:

Sample Code:

MapiMessage mapi = MapiMessage.FromFile("test.msg");

MailMessageInterpretor mi = MailMessageInterpretorFactory.Instance.GetIntepretor(mapi.MessageClass);

MailMessage msg = mi.Interpret(mapi);

Console.WriteLine(msg.From.Address);
Console.WriteLine(msg.From.DisplayName);

Hi Kashif,

I’ve experienced the exact opposite.
The “From” was missing, though the Sender was available.

I’m trying to get the data from the PST file, and not the MSG.
Is there a difference ?

Hi Daniel,


Thanks for writing again.

Could you please provide us the sample PST along with the console application used for this testing? We need to re-produce the scenario where Sender is available and From is missing. It will help us to analyze the requirement and provide assistance at the earliest.

Your cooperation is highly appreciated in this regard.