获取作为 Exchange 用户的收件人的电子邮件地址

发布于 2024-11-14 02:32:39 字数 858 浏览 1 评论 0原文

在我的 VSTO Outlook 2007 插件中,我能够获取作为 Exchange 用户的收件人的电子邮件地址。但是,当我遇到以下情况时,它不会向我返回 smtp 电子邮件:

  1. 添加新的 Outlook 联系人项目(在 Outlook 联系人中)。
  2. 此联系人项目的电子邮件地址应该是交换用户(您组织中的任何人,但属于交换用户)的电子邮件。
  3. 现在,当我选择此 Outlook 联系人作为电子邮件收件人并在项目发送事件中时,我无法获取 smtp 地址。

以下是我的代码:

    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;

任何人都可以帮助我了解在这种情况下我应该使用什么属性来获取 smtp 电子邮件吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月亮坠入山谷 2024-11-21 02:32:39

我找到了一种使用 ExchangeUser 项目并通过该对象解析 smtp 地址的方法。这篇文章有帮助 - 从 Exchange 中存储的 ContactInfo 获取 Smtp 电子邮件

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

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;
        }
    }
深海夜未眠 2024-11-21 02:32:39

如果我没记错的话,在某些情况下,除非您先保存要发送的项目,否则电子邮件地址将无法解析。你可以尝试一下。另外,您是否没有收到任何请求访问用户地址簿权限的“安全违规”消息,或者您是否禁用/解决了所有这些问题?我遇到了很多问题,最终需要使用 Outlook 的赎回。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文