Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting email address of a recipient which is an exchange user

In my VSTO Outlook 2007 plug-in, I am able to get the email address of a recipient which is an exchange user. But when I have the following case, it does not return me the smtp email:

  1. Add a new Outlook Contact item (in Outlook contacts).
  2. The email address of this Contact Item should be an email of an exchange user (any person of your organization, but that is an exchange user).
  3. Now when I select this Outlook contact as email recipient and in item send event I cannot get the smtp address.

Below is my code:

    Recipient r = mailItem.Recipients[i];
r.Resolve();
//Note, i have different conditions that check the AddressEntryUserType of recipient's 
//address entry object. All other cases work fine. In this case this is 
//olOutlookContactAddressEntry. 
//I have tried the following:

 ContactItem cont = r.AddressEntry.GetContact();
 string email = cont.Email1Address;
 string emailtmp = r.AddressEntry.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x800F101E") as string;

Can anyone please help me about what property I should use in this case to get smtp email?

like image 920
Nadeem Ullah Avatar asked Jun 02 '11 19:06

Nadeem Ullah


People also ask

How do I find the user's email address in Exchange server?

Select the recipients you want, add them to the list, and then select OK. You can also search for a specific recipient by typing the recipient's name in the search box and then selecting Search . The Full Access permission allows a delegate to open a user's mailbox and access the contents of the mailbox.

How do I trace an Exchange email?

Open the modern EAC at https://admin.exchange.microsoft.com, expand Mail flow, and then select Message trace.

Can Exchange Admin see emails?

They cannot access your personal email, unless they also have access to the machine you work on.

What is the difference between mail contact and mail user in Exchange?

However, unlike a mail contact, a mail user has sign in credentials in your Microsoft 365 organization and can access resources. For more information about mail contacts and mail users, see Recipients in Exchange Online.


1 Answers

I have found a way to use the ExchangeUser item and resolve the smtp address through that object. This post helped - Get Smtp email from ContactInfo stored in Exchange

    foreach (Outlook.Recipient recipient in currentAppointment.Recipients)
    {
        Outlook.ExchangeUser exchangeUser = recipient.AddressEntry.GetExchangeUser();
        string smtpAddress;
        if (exchangeUser != null)
        {
             smtpAddress = exchangeUser.PrimarySmtpAddress;
        }
        else
        {
             smtpAddress = recipient.Address;
        }
    }
like image 135
kavun Avatar answered Oct 08 '22 06:10

kavun