Get Sender Information From Email - Sender Name/Email Address

We have an email automation process where we extract email information and create a PDF. Lately, we have encountered problems with some emails, as the “Email.Sender” and “Email.From” properties in the email object return null values, and the email sender’s address is missing from the email contact. Is there a workaround to fetch the email sender’s name when the email address is unavailable?

Note: We are using Get Outlook Mail Messages activity to fetch emails. We are avoiding the “Print Email As PDF” activity in UiPath due to timestamp formatting issues and prefer not to handle exceptions with try-catch. Instead, we need a way to retrieve the sender’s name when sender’s email is unavailable. Any suggestions?

Hi @GopiKP ,
To get sender address we can use
mail.From.Address.Tostring
eg:


regards,

Hi,

Thank you for your response. We have attempted using “Email.From.Address.Tostring”, but since “Email.From” returns null, it results in an exception. Our challenge is that the email sender does not have a conventional email address like “Test@Test.com” in the image below. Instead, it has “Sender:This is a test email…” in the sender information. We need to fetch this information.

Hi @GopiKP ,
What’s type of mail you used?
outlook or gmail…?

regards,

@Nguyen_Van_Luong1’s solution should work as that’s the normal way of getting email addresses.

If you are getting additional text along with the email then, you can use regular expressions to get the email.

Hi Nguyen,

We are using Outlook.

Hi Rahul,

Email.From and Email.Sender are returning null and I cannot see any email address in the contact card. For this reason, we are looking to pull contact name instead of email address.

Have you tried using regular expressions to filter out the email from the contact name?

Oh, I always use the above method to get the sender address,
Here I need your help to clarify whether you want to get the sender’s address, or the email address in the body of a certain email?

Hi Rahul,

I have not tried this option. But I can give it a try. Could you please provide any sample solution to user RegEx to fetch contact name from email?

Hi Nguyen,

I need to the sender’s address not the email address in the body.

Oh, can you share your source, I will check and fix it
because, my solution get sender successfully with many process
regards,

Hi Nguyen,

If you look at the image below, it has the sender name “ABC Coaching” but it does not have an email address in the contact card so Email.Sender is running into “Null exception” and failing. Now I am trying to fetch ABC Coaching.

Hi @GopiKP

If you want Sender Name then try this

currentItem.Sender.DisplayName

@GopiKP

If you want Sender Email address then try this

currentItem.Sender.Address

Hi Lakshman,

Thank you for the workaround. There is no email address in the email. I tried Email.Sender, Email.Sender.Address, Email.Sender.DisplayName. Sender is returning null so Email.Sender is not working. I even tried Email.From, that did not help as well.

@GopiKP

mail.Sender.DisplayName should get you the name. Did you have unread emails in your Inbox before running the workflow?

Hi Rahul,

Mail.Sender is returning null. So, mail.sender.Displayname may not work in my case.

Are you able to get any of the sender’s details?

I do not see any sender details in the email contact card except “*** Coaching & …”. I want to fetch “*** Coaching & …”

Usually, the regular emails have email address in the contact card and easy to fetch the email address using email.Sender or Email.From.