none
Outlook VBA macro to find the IM address of the sender of an email RRS feed

  • Question

  • How do I find the IM address that corresponds to the sender of the currently open email? I believe in most cases the sender has an Exchange type of email address. I need the sender's instant message address.


    Frank

    Tuesday, October 1, 2013 9:07 PM

All replies

  • Hi Frank,

    Do you want to get the real email address of sender?

    If yes, the sample below will show the real email address of sender of current openning email:

    Sub GetSenderMailAddress() Dim olItem As Outlook.MailItem If Application.ActiveExplorer.Selection.Count = 0 Then MsgBox "No Items selected!", vbCritical, "Error" Exit Sub End If Set olItem = Application.ActiveInspector.currentItem

    If olItem.sender.AddressEntryUserType = olExchangeUserAddressEntry Or _ olItem.sender.AddressEntryUserType = olExchangeRemoteUserAddressEntry Then Dim exchangeUser As exchangeUser Set exchangeUser = olItem.sender.GetExchangeUser() MsgBox exchangeUser.PrimarySmtpAddress Else MsgBox olItem.sender.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x39FE001E") End If Set olItem = Nothing End Sub


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Wednesday, October 2, 2013 10:28 AM
    Moderator
  • Thank you for the information. That does work to give me the email address, but how do I get the IM address?

    Regards,


    Frank

    Thursday, October 3, 2013 5:11 PM
  • What do you want to do?

    If you want to send IM, try this code:

    Sub sendIM(toUsers As String, message As String)
    
        Dim msgr As CommunicatorAPI.IMessengerConversationWndAdvanced
    
       'Open messenger window and send message!!!!!
        Set msgr = messenger.InstantMessage(toUsers)
        msgr.SendText (message)
        Set msgr = Nothing
    End Sub
    toUsers is the SMTP email address.
    • Edited by Andy_mic Friday, October 4, 2013 5:23 AM
    Friday, October 4, 2013 5:23 AM