none
SenderName copied to Journal Contacts/From RRS feed

  • Question

  • Outlook 2007: I have a task to copy an email sender name to a journal item. I can easily do this by copying it to the "Contacts" field but as a text. I managed to add the "From" field to the journal item form and copy SenderName  but it is displayed as "my name on behalf of SenderName" and cannot be doubleclicked to get contact details . Can you please advise on how to copy SenderName to a journal entry so that this name is autochecked?

    Set nsOutlook = oApp.GetNamespace("MAPI")
    Set oFolder = nsOutlook.GetDefaultFolder(olFolderJournal)
    Set jItem = oApp.CreateItem(olJournalItem)
    jItem.Display
    jItem.Subject = oItem.Subject
    jItem.UserProperties.Item(4).Value = oItem.SenderName

    Thursday, January 9, 2014 12:39 AM

Answers

  • Hello talantar,

    Note, a journal entry represents a record of all Outlook-moderated transactions for any given period. It doesn't provide the Send method for sending journal items. Anyway, I see the following possible ways for getting the sender details (name, e-mail address and etc.):

    1. You can use the Sender property instead of SenderName. It returns an instance of the AddressEntry class that corresponds to the user of the account from which the item was sent. The AddressEntry class provides the Name property and the GetContact method for getting the corresponding contact from the address book if such exists. For example, I have found the following sample code which shows the described functionality:

    Public Sub DisplaySenderDetails() 
     Dim Explorer As Outlook.Explorer 
     Dim CurrentItem As Object 
     Dim Sender As Outlook.AddressEntry 
     Dim Contact As Outlook.ContactItem 
     
     Set Explorer = Application.ActiveExplorer 
     
     ' Check whether any item is selected in the current folder. 
     If Explorer.Selection.Count Then 
     
     ' Get the first selected item. 
     Set CurrentItem = Explorer.Selection(1) 
     
     ' Check for the type of the selected item as only the 
     ' MailItem object has the Sender property. 
     If CurrentItem.Class = olMail Then 
     Set Sender = CurrentItem.Sender 
     
     ' There is no sender if the item has not been sent yet. 
     If Sender Is Nothing Then 
     MsgBox "There's no sender for the current email", vbInformation 
     Exit Sub 
     End If 
     
     Set Contact = Sender.GetContact 
     
     If Not Contact Is Nothing Then 
     ' The sender is stored in the contacts folder, 
     ' so the contact item can be displayed. 
     Contact.Display 
     
     Else 
     ' If the contact cannot be found, display the 
     ' address entry in the properties dialog box. 
     Sender.Details 0 
     End If 
     End If 
     End If 
    End Sub
    
     

    2. Instead of using the SenderName you may use the SenderEmailAddress property. It returns a String that represents the e-mail address of the sender of the Outlook item.

    Finally, you may try to extract the sender name from the string you get: "my name on behalf of SenderName". You can find the list of available string functions in MSDN.

    Thursday, January 9, 2014 11:31 AM
  • Hi,

    Do you mean that you want to copy the SenderName to a custom “From” field of a journal entry, then the text in the “From” field will be autochecked and support double-clicking to open the contact list?

    As far as I know, the build-in “To”, “Cc”, “Bcc” field in a mail item could automatically check the typed name is related to the type of the textbox field. When the type is Recipient, the name string in this field will be autochecked, and when you double click the name string, it will open a contact list.

    When you develop a mail message form, you could see the properties of “To” field as below.

     


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Thursday, January 9, 2014 11:48 AM
    Moderator

All replies

  • Hello talantar,

    Note, a journal entry represents a record of all Outlook-moderated transactions for any given period. It doesn't provide the Send method for sending journal items. Anyway, I see the following possible ways for getting the sender details (name, e-mail address and etc.):

    1. You can use the Sender property instead of SenderName. It returns an instance of the AddressEntry class that corresponds to the user of the account from which the item was sent. The AddressEntry class provides the Name property and the GetContact method for getting the corresponding contact from the address book if such exists. For example, I have found the following sample code which shows the described functionality:

    Public Sub DisplaySenderDetails() 
     Dim Explorer As Outlook.Explorer 
     Dim CurrentItem As Object 
     Dim Sender As Outlook.AddressEntry 
     Dim Contact As Outlook.ContactItem 
     
     Set Explorer = Application.ActiveExplorer 
     
     ' Check whether any item is selected in the current folder. 
     If Explorer.Selection.Count Then 
     
     ' Get the first selected item. 
     Set CurrentItem = Explorer.Selection(1) 
     
     ' Check for the type of the selected item as only the 
     ' MailItem object has the Sender property. 
     If CurrentItem.Class = olMail Then 
     Set Sender = CurrentItem.Sender 
     
     ' There is no sender if the item has not been sent yet. 
     If Sender Is Nothing Then 
     MsgBox "There's no sender for the current email", vbInformation 
     Exit Sub 
     End If 
     
     Set Contact = Sender.GetContact 
     
     If Not Contact Is Nothing Then 
     ' The sender is stored in the contacts folder, 
     ' so the contact item can be displayed. 
     Contact.Display 
     
     Else 
     ' If the contact cannot be found, display the 
     ' address entry in the properties dialog box. 
     Sender.Details 0 
     End If 
     End If 
     End If 
    End Sub
    
     

    2. Instead of using the SenderName you may use the SenderEmailAddress property. It returns a String that represents the e-mail address of the sender of the Outlook item.

    Finally, you may try to extract the sender name from the string you get: "my name on behalf of SenderName". You can find the list of available string functions in MSDN.

    Thursday, January 9, 2014 11:31 AM
  • Hi,

    Do you mean that you want to copy the SenderName to a custom “From” field of a journal entry, then the text in the “From” field will be autochecked and support double-clicking to open the contact list?

    As far as I know, the build-in “To”, “Cc”, “Bcc” field in a mail item could automatically check the typed name is related to the type of the textbox field. When the type is Recipient, the name string in this field will be autochecked, and when you double click the name string, it will open a contact list.

    When you develop a mail message form, you could see the properties of “To” field as below.

     


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Thursday, January 9, 2014 11:48 AM
    Moderator