Retrieving E-mail Body and Sender Details

email
outlook
activities
p_qa

#1

Hi All,

I’m attempting to grab e-mails using the Get Outlook Mail Messages activity. The e-mails are output to a MailMessage List and then a for each loop allows me to extract the Email.Subject and Email.Headers(“Date”) absolutely fine. however I cannot seem to get the sender or the body of the E-mail.

Email.Body, Email.Sender.Address, E-mail.From.Address all return the following Error

Main has thrown an exception

Message: Object reference not set to an instance of an object. This error usually occurs when using a variable with no set value (not initialized).

Source: Log message

Exception Type: NullReferenceException

System.NullReferenceException: Object reference not set to an instance of an object.

It’s almost as if it’s not actually reading in any information for these, however Subject and Headers works so I’m really confused… any suggestions?


#2

Only Email.Sender.Address is giving error from me, remaining works. Can you attach your Xaml.


#3

Hi Vvaidya,

XAML attached.

Main.xaml (9.8 KB)

I’m wondering whether perhaps its some setting within outlook that’s preventing certain parts of E-mails from being read?

As far as I can tell from watching the video tutorials my syntax seems to be correct?


#4

You may try this to answer your question

In Outlook 2016, 2013, or 2010
In an open email message, click the File tab.

On the Info tab, click Properties.

Header information appears in the Internet headers box.


#5

Tried that this morning and indeed I can see header information in that section, which I’d expect anyway as the header details seem to be the only data being returned. I’ve also been through all the relevant outlook settings that I can find and checked for obvious things such an ensuring that the full e-mail is downloaded, not just headers etc etc, but still no luck :frowning:


#6

Hello.

For email datatypes some attributes are not always defined. Email.Sender I think is a problem one because sometimes in not defined for normal emails. For that I think you can use Email.From. Another example are no reply emails. Depending on how the email is created no replies have some proprieties empty.


#7

I’ve tried both From and Sender and neither are returning anything, along with Body. So far the only attributes I have got to work correctly is the Subject and the Headers

adding a count to the attribute for body, Sender and From IE Mail.Body.Count results in a response of 0 which to me suggests it’s not pulling back any data when grabbing the Mailmessage from outlook.


#8

So, I’ve now managed to get the E-mails using “Get Exchange Mail Messages” activity rather than the get outlook mail messages, and in this instance I’m able to get the body, sender and from details with no issue, Therefore I’m now pretty sure it must be something to do with the way our outlook is configured. I’ll keep playing with it and update if I figure out why.


#9

I have looked into that xaml file…
.body is working fine for me…
.sender is not at all working without reason…
.from is working fine…
May be outlook version doesnt decide it may be UiPath version dependency…

:slight_smile:


#10

Can someone let me know if we were able to resolvr this?


#11

Can you please share XAML file, Thank you!


#12

Hi,

It’s resolved in terms that I get results when using the “get exchange email” however i still get nothing other than header and subject details when using “Get outlook mail” which therefore makes me think its some bizarre setting within outlook that is preventing UIPath from integrating fully. I’ve been through all the options and settings that I can find within Outlook that look likely but no luck.

“Get Exchange Mail” will work for me for now, however from what I’ve read it’s not able to pick up E-mails from Shared Mailboxes, which might be a bit of a blocker moving forwards.


#13

Agreed I had the same issue with shared inbox it doesn’t have sender details so I did a try catch for the known exception if there is no sender address in the email


#14

Hmm I also had this problem and again the .from option seems to have worked in a try catch activity.


#15

Is there anyway to automate this process without the use of click?


#16

Hello,
I’m facing the same issue, getting an error when tring to get the Sender or From detail of a mailmessage.
Is somebody in UiPath looking at this issue ?
Thanks and regards


#17

Hi Nicolas,

What’s the error message? The initial one: Object reference not set to an instance of an object. This error usually occurs when using a variable with no set value (not initialized).?

Could you please provide the Studio version and the UiPath.Mail.Activities package version?


#18

Yes this same error.

UiPath version : 2017.1.6435
UiPath.Mail.Activities package version : 1.1.6382.14550

Thanks


#19

Can you upgrade to latest Mail Package (on Gallery feed) ?


#20

Ok. We face the same problem. It is apparent that UIPath manipulates the header information in Get Outlook Messages activity. It can be seen when analysing e-mails sent from shared vs. personal e-mail account. Outlook displays an e-mail sent from a shared mailbox as, for example: "my.name@domain.com on behalf of shared_name@domain.com). When an e-mail is sent from a personal mailbox, its header doesn’t have “Sender” at all (at least when sent from Outlook). Sender header is only set when the e-mail was sent from a shared mailbox.

Problem is, that UIPath is unable to get the shared mailbox address (on behalf of), while REPLACING the “From” header by “Sender” and having the .Sender method item undefined (which will result in NullReferenceException error). So you always get the originator, but you cannot tell whether the e-mail was sent from a shared account or not.