none
3rd party outlook add-on (developer support) RRS feed

  • Question

  • We have developed an  outlook plugin in C# that uses vsto technology. The purpose of this plugin is that outlook users can tag or copy an outlook email onto our platform.  Users simply click on the add on, sign in to it with their credentials (on our system), and finally select an email in outlook and associate it with our system. The message will then be displayed on our portal. https://help.zolasuite.com/portal/en/kb/articles/how-do-i-use-the-outlook-plugin

    When emails are sent internally, the email addresses are in x500 format such as "/o=ExchangeLabs/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=

    If the outlook is 32-bit, we can use MAPI to extract the sender email address based on the x500 string. However, if the outlook is 64-bit, the MAPi does not work.

    Question: Given an email object from outlook 64-bit and the sender's email address obtained from the email object is in x500 format, how can we use MAPI to extract the sender's email address from this x500 format?

    We get the object names such as From, To, etc. directly from outlook using our plugin.

    Thanks

    bobby


    Tuesday, June 30, 2020 4:58 PM

All replies

  • MAPI works just fine in 64 bit.

    But you don't need MAPI to extract a an SMTP address - for a given AddressEntry object (e.g. returned from MailItem.Sender or Recipient.AddresEntry), check the value of the AddressEntry.Type property- if it is anything but "EX", just use the AddressEntry.Address property. Otherwise, use AddressEntry.GetExchangeuser().PrimarySMTPAddress (be prepared to handle nulls and exceptions).


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Tuesday, June 30, 2020 5:41 PM
  • Hello Bobby,

    As Dmitry wrote, there is no need to use MAPI for that until you need to support older Outlook versions (2010 and earlier).

    See HowTo: Convert Exchange-based email address into SMTP email address for the sample code.


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Tuesday, June 30, 2020 7:31 PM
  • Thanks for the info. 

    We do use "AddressEntry.GetExchangeuser().PrimarySMTPAddress" for obtaining the sender's email address for composing new emails, forwarding and replying to existing emails. What we are looking to achieve is to get the sender's email address of a selected email from the Inbox and the sender's email address is in X500 format as described in the original post.  There is no valid email address that can be used or obtained from MailItem.Sender or Recipient.AddresEntry. Address. Please see the screenshot for more information.

    see here; https://prnt.sc/tcsb5x


    Monday, July 6, 2020 2:10 PM
  • So have you tried to use MailItem.Sender.GetExchangeuser().PrimarySMTPAddress ?

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!


    Monday, July 6, 2020 7:54 PM
  • Yes, we have used MailItem.Sender.GetExchangeuser().PrimarySMTPAddress to obtain the sender's email address when composing new emails and replying and forwarding emails. When selecting an email from the Inbox and the email address is in X500 format, we can't use MailItem.Sender.GetExchangeuser().PrimarySMTPAddress because the sender can be anyone, not necessarily the current logon outlook user.
    Monday, July 6, 2020 8:04 PM
  • What does it have to do with the current profile owner? MailItem.Sender.GetExchangeuser().PrimarySMTPAddress will give you the SMTP address of the *sender*.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Monday, July 6, 2020 11:19 PM
  • We have this in our logic however, MailItem.Sender.GetExchangeuser().PrimarySMTPAddress returns an empty string when the email address is in X500 format

    Thanks Dmitry

    Tuesday, July 7, 2020 1:45 PM
  • That can happen if the current profile does not contain the original Exchange server that hosts the GAL entry.

    In most cases however, the message woudl contain the PidTagSenderSmtpAddress MAPI property (DASL name "http://schemas.microsoft.com/mapi/proptag/0x5D01001F"). Take a look at the message with OutlookSpy (click IMessage button).


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Tuesday, July 7, 2020 3:16 PM