【发布时间】:2022-04-20 12:55:57
【问题描述】:
我迭代所有 AppointmentItem.Recipients。对于每个收件人,我使用以下实用程序方法来检索收件人“正常”的 SMTP 电子邮件地址:
为此,我使用了来自 stackoverflow 的帖子:Getting email address from a Recipient object
public static string GetSmtpAddress(Outlook.AddressEntry addressEntry)
{
String smtpAddress;
if (addressEntry.Type == "EX")
{
if (addressEntry.AddressEntryUserType == Outlook.OlAddressEntryUserType.olExchangeUserAddressEntry
|| addressEntry.AddressEntryUserType == Outlook.OlAddressEntryUserType.olExchangeRemoteUserAddressEntry)
{
Outlook.ExchangeUser user = addressEntry.GetExchangeUser();
smtpAddress = user != null ? user.PrimarySmtpAddress : null;
}
else if (addressEntry.AddressEntryUserType == Outlook.OlAddressEntryUserType.olOutlookContactAddressEntry)
{
//returns the actual contact but it has 3 email properties (Email1Address, Email2Address, Email3Address).
//How to identify which email has the user selected
Outlook.ContactItem cont = addressEntry.GetContact();
String OABID = addressEntry.ID;
String typ = OABID.Substring(29 * 2, 2);
if (typ=="00")
{
smtpAddress = cont.Email1Address; <!-- Strange Emailadress
}else if (typ=="01")
{
smtpAddress = cont.Email1Address;
} else
{
smtpAddress = cont.Email2Address;
}
} else
{
smtpAddress = "";
}
}
else if (addressEntry.Type == "SMTP")
{
smtpAddress = addressEntry.Address;
}
else
{
smtpAddress = "";
}
return smtpAddress;
}
标有
我正在寻找的是一个 100% 强大的实用程序功能,无论收件人是什么地址类型、Exchange 用户、地址簿用户或其他任何类型,它都能检索正确的 SMTP 地址。非常感谢任何帮助。
最好的问候 汉内斯
【问题讨论】:
标签: vsto outlook-addin