1

I'm using PST-Parser to parse .pst files. Most of this is working, but I am having a problem when a message contains a recipient who is on an Exchange server, at least, I think that's the problem.

If I look at the raw message headers in Outlook, I can see something like this...

To: Jim1 <jim1@jim.com>
Cc: Jim2 <jim2@jim.com>, 
    Jim3 <jim3@jim.com>, 
    Someone Else <someone@else.co.uk>

As you can see, the email addresses for everyone @jim.com are stored in SMTP format, which is the format I need to display to the end user.

When I try to get the email address in code, I get something like this...

/o=ExchangeLabs/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=404f8ca9734d4114bfbb1854d6336f55-jim1

The code I'm using to get the addresses is simple enough. Given a Message object, I can get (say) the first "To" recipient as follows...

Recipient recip = message.Recipients.To.First();

...and the email address as follows...

string email = recip.EmailAddress;

This works fine for most recipients, but for some, gives the odd code shown earlier. According to this answer (which relies on Outlook automation, which I can't use), the code shown above is a valid EX address. However, I need the SMTP address, eg jim1@jim.com to display to the end user.

Anyone any idea how I can get the SMTP address? It's clearly in the message headers, so should be available. What puzzles me is that the EX address returned doesn't even appear in the raw headers, so I have no idea where that is coming from.

Thanks for any help you can give.

Avrohom Yisroel
  • 8,555
  • 8
  • 50
  • 106
  • You may have to order the To and CC and BCC fields manually. – James McLeod Oct 06 '21 at 14:41
  • @JamesMcLeod Not sure what you mean. The usage of `First` I showed was just to simplify the code. However I access the recipients in the `To` and `CC` collections, the `EmailAddress` property shows the same. Please can you clarify what you mean. Thanks for the reply – Avrohom Yisroel Oct 06 '21 at 16:24

0 Answers0