none
How to get Recipient Address property? RRS feed

  • Question

  • Hi everyone.

    I need do some thing based on the Recipient Address in the ItemSend Event, but how can I get the complete Recipient Address, including domain? Thanks in advance.

    Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    
        If Recipient.Address.indexof("@DomainName.Com")>-1 Then  'How to get Recipient.Address property?
        
            '....
            
        End If
        
    End Sub


    • Edited by leon1526 Tuesday, January 17, 2017 7:55 AM update
    Tuesday, January 17, 2017 7:54 AM

Answers

  • Hello Leon,

    You can use the Recipients property of the MailItem class (if the item passed as a parameter is a MailItem) which returns a Recipients collection that represents all the recipients for the Outlook item. A recipient can be specified by a string representing the recipient's display name, alias, or full SMTP e-mail address. But before sending all recipients should be resolved against an address book (get corresponding entries with email addresses). So, you may check the Address property of the Recipient class or just use the following sequence of calls:

     
    Recipient.AddressEntry.Address


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

    • Proposed as answer by Chenchen LiModerator Wednesday, January 18, 2017 1:45 AM
    • Marked as answer by leon1526 Wednesday, January 18, 2017 11:08 AM
    Tuesday, January 17, 2017 11:02 AM

All replies

  • Hello Leon,

    You can use the Recipients property of the MailItem class (if the item passed as a parameter is a MailItem) which returns a Recipients collection that represents all the recipients for the Outlook item. A recipient can be specified by a string representing the recipient's display name, alias, or full SMTP e-mail address. But before sending all recipients should be resolved against an address book (get corresponding entries with email addresses). So, you may check the Address property of the Recipient class or just use the following sequence of calls:

     
    Recipient.AddressEntry.Address


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

    • Proposed as answer by Chenchen LiModerator Wednesday, January 18, 2017 1:45 AM
    • Marked as answer by leon1526 Wednesday, January 18, 2017 11:08 AM
    Tuesday, January 17, 2017 11:02 AM
  • Hi Eugene Astafiev,

    Thank you very much for your prompt reply!

    Wednesday, January 18, 2017 11:08 AM