Getting email address from a Recipient object

一曲冷凌霜 提交于 2019-12-20 06:44:07

问题


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

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.

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?


回答1:


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.



来源:https://stackoverflow.com/questions/39391340/getting-email-address-from-a-recipient-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!