从收件人对象获取电子邮件地址 [英] Getting email address from a Recipient object
问题描述
我正在开发VSTO插件,当发送新电子邮件时,该插件需要读取所有电子邮件地址.下面是我现在正在使用的代码,但是在某些情况下无法正常工作.
I’m developing a VSTO addin which needs to read all the email address when a new email is being sent out. Below is the code I’m using right now but it is not working in few cases.
if (addr.Type == "EX")
{
if (addr.AddressEntryUserType == OlAddressEntryUserType.olExchangeUserAddressEntry
|| addr.AddressEntryUserType == OlAddressEntryUserType.olExchangeRemoteUserAddressEntry)
{
exch = addr.GetExchangeUser();
smtpAddress = exch != null ? exch.PrimarySmtpAddress : null;
}
else if (addr.AddressEntryUserType == OlAddressEntryUserType.olOutlookContactAddressEntry)
{
cont = addr.GetContact();
//returns the actual contact but it has 3 email properties (Email1Address, Email2Address, Email3Address).
//How to identify which email has the user selected
}
}
else if (addr.Type == "SMTP")
{
smtpAddress = addr.Address;
}
如果AddressEntryUserType为olExchangeUserAddressEntry或olExchangeRemoteUserAddressEntry,则代码工作正常.但是,如果它是本地Outlook联系人(olOutlookContactAddressEntry),则我不确定如何获取电子邮件地址. GetContact方法为我提供了实际的联系方式,但是由于它有3封电子邮件,我不知道如何查找用户在撰写电子邮件时选择的地址.
If the AddressEntryUserType is olExchangeUserAddressEntry or olExchangeRemoteUserAddressEntry then the code is working fine. But if it is a local outlook contact (olOutlookContactAddressEntry) I’m not sure on how to retrive the email address. The GetContact method gives me the actual contact but since it has 3 emails I don’t know on how to find which address has the user choosen while composing the email.
我已经尝试过将Exchange中基于Exchange的电子邮件地址转换为SMTP,如本论坛所述.但这给性能带来了巨大的影响.一种地址转换为SMTP大约需要300毫秒.还有其他有效的方法可以从收件人对象中识别电子邮件地址吗?
I have already tried converting the Exchange based email address to SMTP as discussed on this forum. But it is giving a huge performance impact. It takes around 300ms for one addres to be converted to SMTP. Is there any other efficient way to identify the email address from a Recepient object?
推荐答案
所选索引嵌入在OAB条目ID中-检查前20个字节是否为0x00,0x00,0x00,0x00,0xFE,0x42,0xAA,0x0A,0x18,0xC7,0x1A,0x10,0xE8,0x85,0x0B,0x65,0x1C,0x24,0x00,0x00
字节25是类型(0x5是DL,0x4是接触).字节29是索引(仅用于联系人):0 =电子邮件1,1 =电子邮件2,2 =电子邮件3,3 =商业传真,4 =家庭传真,5 =其他传真.
The selected index is embedded in the OAB entry id - check that the first 20 bytes are 0x00,0x00,0x00,0x00,0xFE,0x42,0xAA,0x0A,0x18,0xC7,0x1A,0x10,0xE8,0x85,0x0B,0x65,0x1C,0x24,0x00,0x00
Byte 25 is type (0x5 is DL, 0x4 is contact). Byte 29 is index (for contact only): 0 = email1, 1 = email2, 2 = email3, 3 = business fax, 4 = home fax, 5 = other fax.
这篇关于从收件人对象获取电子邮件地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!