«

»

Jan
08
2012

Reading Outlook Recipient Details (JobTitle, Alias, Address etc) Through VBA

Outlook MacroHere is a piece of outlook VBA code which can be used to read recipient details such as JobTitle, Alias, Address etc. While there are many complex work around exist for this I believe the code below will simplify the details capture with the help of outlook ‘exchange user’ property.

 



 
 

Sub ReadRecpDetail()

”””’Declarations

Dim myOlApp As Outlook.Application

Dim myItem As Outlook.MailItem

Dim myRecipient As Outlook.Recipient

 

Set myOlApp = CreateObject(“Outlook.Application”)

Set myItem = myOlApp.CreateItem(olMailItem)

 

”””’add some recipient

Set myRecipient = myItem.Recipients.Add(“email.ID@domain.com”)

 

”””read one of the details of reipient

MsgBox (myRecipient.AddressEntry.GetExchangeUser.JobTitle)

 

”””””””’Some Options”””””””””””””

‘ myRecipient.AddressEntry.GetExchangeUser.Alias

‘ myRecipient.AddressEntry.GetExchangeUser.Department

‘ myRecipient.AddressEntry.GetExchangeUser.Name

‘ myRecipient.AddressEntry.GetExchangeUser.Address

‘ myRecipient.AddressEntry.GetExchangeUser.City

 

‘open up the e-mail message [optional]

myItem.Display

 

End Sub

 

Please note that ‘exchange user’ feature or getExchangeUser function not supported by the older version exchange servers. So ensure that the exchange server compatible with MS office outlook 2007 or higher.

 

Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>