Send Email to Outlook Exchange Email

I read My contacts from my Outlook contacts and then add the contact to MailMessage mail.To.Add("John Doe <John Doe>") , but I get this error:

The specified string is not in the form required for the email address.

How can i solve this? when I read from Outlook contacts, the result for the email address is a long string like this (only for Exchange account types) and I want to get the last value cn =: /o=First Organization/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=John Doe

How can I read the correct email address from my Exchange account ( jDoe@example.com ) or another method to send email?

+4
source share
1 answer

If you have ExchangeUser , you can access the PrimarySmtpAddress property for Exchange email. Then the following should work for you:

 MailMessage mail = new MailMessage(); mail.To.Add(exchangeUser.PrimarySmtpAddress); 
+3
source

All Articles