开发者

Getting email address of a recipient which is an exchange user

开发者 https://www.devze.com 2023-03-10 13:12 出处:网络
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:

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 th开发者_运维知识库e 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?


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;
        }
    }


If I recall correctly, there were several instances where email addresses wouldn't resolve unless you SAVED the item being sent first. You might try that. Also, are you not getting any "security violation" messages asking for permission to access the user's address book, or have you disabled/worked around all that stuff? I had lots of probs with that that ended up requiring using Redemption for outlook.

0

精彩评论

暂无评论...
验证码 换一张
取 消