none
Can't get the Recipient Email Address to display correctly in the Sent Folder RRS feed

  • Question

  • So I've been using Outlook 2013 and 2016 on this issue but no luck so far. I've tried following the instructions (here; http://www.slipstick.com/developer/recipient-email-address-sent-items/?subscribeAnchor&subscriptionSuccess=1#wc_unsubscribe_message) to create a custom macro for it but it won't work. I don't know alot about macros but I tried following this guide here:

    http://www.slipstick.com/developer/how-to-use-outlooks-vba-editor/

    I tried posting the question over in the Outlook IT Pro Discussions section of this site but didn't really get to many responses.

    Wednesday, April 20, 2016 4:26 PM

All replies

  • Hello,

    See Getting Started with VBA in Outlook 2010 .

    The page explains two things:

    1. Add a user property with a recipient email address (described in the article mentioned).

    2. Add the property to the view (manually). However, you can customize the View programmatically. The CurrentView property of the Folder class returns a View object representing the current view. To obtain a View object for the view of the current Explorer, use Explorer.CurrentView instead of the CurrentViewproperty of the current Folder object returned by Explorer.CurrentFolder.

    The View object allows you to create customizable views that allow you to better sort, group and ultimately view data of all different types. There are a variety of different view types that provide the flexibility needed to create and maintain your important data.

    • The table view type (olTableView) allows you to view data in a simple field-based table.
    • The Calendar view type (olCalendarView) allows you to view data in a calendar format.
    • The card view type (olCardView) allows you to view data in a series of cards. Each card displays the information contained by the item and can be sorted.
    • The icon view type (olIconView) allows you to view data as icons, similar to a Windows folder or explorer.
    • The timeline view type (olTimelineView) allows you to view data as it is received in a customizable linear time line.

    Views are defined and customized using the View object's XML property. The XML property allows you to create and set a customized XML schema that defines the various features of a view.

    The XML definition describes the view type by using a series of tags and keywords corresponding to various properties of the view itself. When the view is created, the XML definition is parsed to render the settings for the new view.

    To determine how the XML should be structured when creating views, you can create a view by using the Outlook user interface and then you can retrieve the XML property for that view.

    You may find the Outlook 2013/2016 - Customizing the Outlook view page helpful.


    [custom.development]

    Wednesday, April 20, 2016 4:44 PM
  • Hi, Greenthumb Computers

    According to your description, if you want to obtain the SMTP address for each recipient in a Recipients collection, you could refer to below code:
    Sub Demo()
    
        Dim NS As Outlook.NameSpace
        Dim recips As Outlook.Recipients
        Dim recip As Outlook.Recipient
        Dim pa As Outlook.propertyAccessor
        Const PR_SMTP_ADDRESS As String = _
            "http://schemas.microsoft.com/mapi/proptag/0x39FE001E"
            
        Set NS = Application.GetNamespace("MAPI")
        Set olsent = NS.GetDefaultFolder(olFolderSentMail).Items
        
        For Each mail In olsent
            Set recips = mail.Recipients
            For Each recip In recips
                Set pa = recip.propertyAccessor
                Debug.Print recip.Name & " SMTP=" _
                   & pa.GetProperty(PR_SMTP_ADDRESS)
            Next
        Next
        
    End Sub

    For more information, click here to refer about Obtain the E-mail Address of a Recipient


    Thursday, April 21, 2016 3:18 AM
  • Hi David,

    Thanks for the reply! Below is what I have so far that isn't working. Should I just replace it with the lines you suggested or would I add it in to what is below (and if so which line do i drop it into)?

    Here's what I got so far:

    Dim WithEvents olSent As Items

    Private Sub Application_Startup()
       Dim NS As Outlook.NameSpace
       Set NS = Application.GetNamespace("MAPI")
       Set olSent = NS.GetDefaultFolder(olFolderSentMail).Items
       Set NS = Nothing
    End Sub

    Private Sub olSent_ItemAdd(ByVal Item As Object)
        ' From http://slipstick.me/1
        Dim objProp As Outlook.UserProperty
        Dim strDomain As String
        Dim Recipients As Outlook.Recipients
        Dim recip As String 'Outlook.Recipient
        Dim i

    strDomain = ""
    Set Recipients = Item.Recipients
      For i = Recipients.Count To 1 Step -1
         recip$ = Recipients.Item(i).Address

        If InStr(1, LCase(recip), "/ou=") Then
    recip = Right(recip, Len(recip) - InStr(1, LCase(recip), "recipients") - 13)
    recip = Right(recip, Len(recip) - InStr(1, LCase(recip), "-"))
     End If
      Next i

      Set objProp = Item.UserProperties.Add("Recipient Email", olText, True)
        objProp.Value = strDomain
        Item.Save

        Err.Clear

        Set objProp = Nothing
        Set Recipients = Nothing

     End Sub

    Thanks for dealing with me here!

    Monday, April 25, 2016 2:42 PM
  • >>>Thanks for the reply! Below is what I have so far that isn't working. Should I just replace it with the lines you suggested or would I add it in to what is below (and if so which line do i drop it into)?<<<

    According to your description, could you provide more information about what I have so far that isn't working? 
    In addition you could modify your code like below:
    Private Sub olSent_ItemAdd(ByVal item As Object)
    
    Dim recips As Outlook.Recipients
    Dim recip As Outlook.Recipient
    Dim pa As Outlook.propertyAccessor
    Const PR_SMTP_ADDRESS As String = _
       "http://schemas.microsoft.com/mapi/proptag/0x39FE001E"
    
    Set recips = item.Recipients
    For Each recip In recips
        Set pa = recip.propertyAccessor
        Debug.Print recip.Name & " SMTP=" _
           & pa.GetProperty(PR_SMTP_ADDRESS)
    Next
    
    End Sub
    After that, can you get the Recipient Email Address?
    Tuesday, April 26, 2016 7:40 AM
  • So your saying that I should change it to this:

    Dim WithEvents olSent As Items


    Private Sub Application_Startup()
       Dim NS As Outlook.NameSpace
       Set NS = Application.GetNamespace("MAPI")
       Set olSent = NS.GetDefaultFolder(olFolderSentMail).Items
       Set NS = Nothing
    End Sub

    Private Sub olSent_ItemAdd(ByVal item As Object)

    Dim recips As Outlook.Recipients
    Dim recip As Outlook.Recipient
    Dim pa As Outlook.propertyAccessor
    Const PR_SMTP_ADDRESS As String = _
       "http://schemas.microsoft.com/mapi/proptag/0x39FE001E"

    Set recips = item.Recipients
    For Each recip In recips
        Set pa = recip.propertyAccessor
        Debug.Print recip.Name & " SMTP=" _
           & pa.GetProperty(PR_SMTP_ADDRESS)
    Next

    End Sub

      Set objProp = Item.UserProperties.Add("Recipient Email", olText, True)
        objProp.Value = strDomain
        Item.Save

        Err.Clear

        Set objProp = Nothing
        Set Recipients = Nothing

     End Sub

    Wednesday, April 27, 2016 1:34 PM
  • When I try the code that I included before I don't see any anything in the Recipient Email section at all. After adding the lines you gave me it gives this error-

    Compile error:

    Only comments may appear after End Sub, End Function, or End Property

    Wednesday, April 27, 2016 2:04 PM
  • >>>Compile error:

    Only comments may appear after End Sub, End Function, or End Property<<<

    According to your description, I have found that there are some mistake in your sample codes, I suggest that you could modify below:
    Private Sub olSent_ItemAdd(ByVal item As Object)
    
    Dim recips As Outlook.Recipients
    Dim recip As Outlook.Recipient
    Dim pa As Outlook.propertyAccessor
    Const PR_SMTP_ADDRESS As String = _
       "http://schemas.microsoft.com/mapi/proptag/0x39FE001E"
    
    Set recips = item.Recipients
    For Each recip In recips
        Set pa = recip.propertyAccessor
        Debug.Print recip.Name & " SMTP=" _
           & pa.GetProperty(PR_SMTP_ADDRESS)
    Next
    
    
        Set objProp = Item.UserProperties.Add("Recipient Email", olText, True)
        objProp.Value = strDomain
        Item.Save
    
        Err.Clear
    
        Set objProp = Nothing
        Set Recipients = Nothing
    
     End Sub
    Friday, April 29, 2016 7:11 AM
  • Hey David,

    After I dropped in those lines you gave me it fixed the error. However weirdly when testing the macro when I send a test email to someone within my company on the exchange server nothing shows up in the Recipients Emails column anymore. Not even the long confusing OU x500 info.

    Not sure why that is suddenly happening. Any ideas?

    Friday, April 29, 2016 1:54 PM
  • >>>However weirdly when testing the macro when I send a test email to someone within my company on the exchange server nothing shows up in the Recipients Emails column anymore. Not even the long confusing OU x500 info.

    Not sure why that is suddenly happening. Any ideas?<<<

    According to your description, could you provide more information about this issue, for example sample code, screenshot etc., that will help us reproduce and resolve it.

    Thanks for your understanding.
    Monday, May 2, 2016 7:41 AM
  • I'm not sure why but its not letting me post any screenshots. I keep getting the message that I need to verify my account but I did that 2 weeks ago. I can't figure out how to get Microsoft to resend the verification email.
    Monday, May 2, 2016 7:58 PM
  • Hi, Greenthumb Computers

    According to your description, I suggest that you could upload screenshot on OneDrive, then you could provide this link.

    Thanks for your understanding.
    Tuesday, May 3, 2016 6:20 AM