Get info from contact RRS feed

  • Question

  • I am looking at putting some information from the contact in the 'to' field and putting it in the subject of an email.

    Currently I have part of the string I have working by using.


    Dim olkMsg As Outlook.MailItem
    'Get the currently open message'
    Set olkMsg = Outlook.Application.ActiveInspector.CurrentItem
    'Set subject to YYMMDD, [TO]
    olkMsg.Subject = Format(Now(), "yymmdd") & olkMsg.To)
    'Destroy the object to avoid memory leaks
    Set olkMsg = Nothing

    What I need to do it go into the contact details associated with '', extract the 'company' information, and then add that to the subject.

    I'm struggling on getting the contact info out. Any help would be amazing.


    Friday, August 9, 2013 4:18 PM

All replies

  • Moving this question to the VSTO forums.

    Monday, August 19, 2013 11:42 PM
  • To is just a text field.

    Use the email's Recipients collection and for each Recipient object get the Recipient.AddressEntry object. Then use AddressEntry.GetContact() to get the relevant ContactItem. That would work only if the Recipient had a corresponding contact item of course.

    If you only want To recipients then check each one for Recipient.Type == olTo.

    Ken Slovak MVP - Outlook

    Tuesday, August 20, 2013 6:35 PM