cancel
Showing results for 
Search instead for 
Did you mean: 

Recipient Email Addresses in Outlook VBO

CraigFarley
Level 3
Is there a way to get all of the recipient email addresses?

I'm using the Outlook VBO which has sender email address but only the display names of the To and CC fields and not their email addresses

------------------------------
Craig Farley
IPI
Europe/London
------------------------------
1 BEST ANSWER

Helpful Answers

AmiBarrett
Level 12

I didn't see an easy way to integrate this into the current code stage without tearing some things apart, so I made it as a separate action, leveraging PrimarySmtpAddress. I'm attaching the XML in a txt file, built in 6.7. You should be able to copy the contents to a clipboard, then paste it in as a new action tab in your VBO.

Alternatively, below is the code stage that I wrote if you want to get it working on your own. It takes the display name and current Outlook profile as an input, then spits out the e-mail address of the display name you've supplied.

Inputs
=====
Profile - Text - Profile name in Outlook, not inbox account e-mail address
displayName - Text - Use one of the names placed in the To/CC field(s) currently populated by the Outlook VBO

Outputs
======
smtpName - Text - The actual e-mail address associated with the display name being checked

Dim app = CreateObject("Outlook.Application")
Dim _nameSpace = app.GetNameSpace("MAPI")
Dim olSharedRecip as object
Dim oEU as Object 'Outlook.ExchangeUser

if Profile <> "" then
    _nameSpace.Logon(Profile, , True, True)
end if

olSharedRecip = _nameSpace.CreateRecipient(displayName)
olSharedRecip.Resolve

if olSharedRecip.Resolved then
	select case olSharedRecip.AddressEntry.AddressEntryUserType
		Case 0, 5 'olExchangeUserAddressEntry & olExchangeUserAddressEntry
			oEU = olSharedRecip.AddressEntry.GetExchangeUser
			if not (oEU is nothing) then
				smtpName = oEU.PrimarySmtpAddress
			end if
		Case 10, 30 'olOutlookContactAddressEntry & 'olSmtpAddressEntry
			smtpName = olSharedRecip.AddressEntry.Address
	end select
end if


------------------------------
Ami Barrett
Sr Product Consultant
Blue Prism
Plano, TX
------------------------------

View answer in original post

10 REPLIES 10

AmiBarrett
Level 12

I didn't see an easy way to integrate this into the current code stage without tearing some things apart, so I made it as a separate action, leveraging PrimarySmtpAddress. I'm attaching the XML in a txt file, built in 6.7. You should be able to copy the contents to a clipboard, then paste it in as a new action tab in your VBO.

Alternatively, below is the code stage that I wrote if you want to get it working on your own. It takes the display name and current Outlook profile as an input, then spits out the e-mail address of the display name you've supplied.

Inputs
=====
Profile - Text - Profile name in Outlook, not inbox account e-mail address
displayName - Text - Use one of the names placed in the To/CC field(s) currently populated by the Outlook VBO

Outputs
======
smtpName - Text - The actual e-mail address associated with the display name being checked

Dim app = CreateObject("Outlook.Application")
Dim _nameSpace = app.GetNameSpace("MAPI")
Dim olSharedRecip as object
Dim oEU as Object 'Outlook.ExchangeUser

if Profile <> "" then
    _nameSpace.Logon(Profile, , True, True)
end if

olSharedRecip = _nameSpace.CreateRecipient(displayName)
olSharedRecip.Resolve

if olSharedRecip.Resolved then
	select case olSharedRecip.AddressEntry.AddressEntryUserType
		Case 0, 5 'olExchangeUserAddressEntry & olExchangeUserAddressEntry
			oEU = olSharedRecip.AddressEntry.GetExchangeUser
			if not (oEU is nothing) then
				smtpName = oEU.PrimarySmtpAddress
			end if
		Case 10, 30 'olOutlookContactAddressEntry & 'olSmtpAddressEntry
			smtpName = olSharedRecip.AddressEntry.Address
	end select
end if


------------------------------
Ami Barrett
Sr Product Consultant
Blue Prism
Plano, TX
------------------------------

Hi Craig,

I would recommend to use MS Exchange VBO which is available in Digital exchange.
It has wide range filters and all the required details as well.

https://digitalexchange.blueprism.com/dx/entry/16835/solution/ms-exchange-functions---agilify

------------------------------
Amlan Sahoo
RPA Consultant
Equinix
------------------------------
Regards,
Amlan Sahoo

Hi Ami

Thanks for the response. I got it to work.

Does it only provide the email address for email addresses that sit on the same email domain?

Can it process more than one display name at a time - if so what's the format?

------------------------------
Craig Farley
Partner Apps Manager
IPI
Europe/London
------------------------------

At present, it only works for one name at a time. (Edit: And yes, it only works for addresses on the domain, as it performs an AD lookup against the account profile.) If more are required, a CSV or collection parser would need to be coded into it.

------------------------------
Ami Barrett
Sr Product Consultant
Blue Prism
Plano, TX
------------------------------

Thanks Ami, really helpful

------------------------------
Craig Farley
Partner Apps Manager
IPI
Europe/London
------------------------------

I got this when trying to run the code in a code stage, would you please help

Internal : Could not execute code stage because exception thrown by code stage: Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT))

16976.png

16977.png

16978.png

16979.png


------------------------------
Raymond Bu
SCM
DXC
Asia/Shanghai
------------------------------

Never mind, i fixed it.
The root cause is that my outlook->trust center->programtic acess greyed out, all outlook related function cannot be used.

------------------------------
Raymond Bu
SCM
DXC
Asia/Shanghai
------------------------------

Hello Ami,

I am working on similar requirement but instead of Display Name, I have to search using the Employee ID. 

We are getting only the Employee ID in input file in format "1234567" and When I put it in TO: email address and press CTRL+K, it populates the email address. 

Could  you please guide me how can I do this using code?

Thanks.



------------------------------
Shweta Singh
Consultant
Ernst & Young LLP
UTC
------------------------------

In theory it should be the same code, as it's just using .Resolve against a string. I've used it against other inputs before (such as DN) and have seen success, but we unfortunately don't have IDs visible where I currently am to test against.



------------------------------
Ami Barrett
Solution Architect
Karsun Solutions
Plano TX
------------------------------