Get Outlook Mail Messages returns emails with subjects, but no other information (body, sender, etc.)

Hello all,

I need to retrieve and use the information contained within the body of an email sent to an email address on Microsoft Outlook. My workflow currently involves using the “Get Outlook Mail Messages” activity to retrieve the unread emails in the inbox, and then attempting to access the contents of the body of the email with the mailMessage.Body call. When I do this with the subject of the email, it works, and I can see the subject of the email of interest currently in my inbox. However, attempting to retrieve the body just returns an empty string. I’ve tried looking at alternative solutions (using the Headers attribute, or the AlternativeView attribute), but neither of these return anything of use. It’s odd - I know I am accessing the correct email because I can get the subject of the email, and I can see it is the one I want, but I can’t get any other information. I feel like it may be related to a security measure put in by my workplace, but I don’t know how to check for that.

Thank you!

TL;DR: I can access the subject lines of emails, and can see the content in them, but I cannot see the body of the email or any other information.

1 Like

Hi Buddy @dwkot

welcome to uipath community
–i hope you were using get outlook mail activity and getting the output with a variable of type list of mailmessages
–using a for each loop and passing the above variable as input and changing the type argument as mailmessage in the for each loop property
–inside the for each loop, use a assign activity like this
out_mailbody = item.Body.ToString
where out_mailbody is a variable of type string

Kindly check with this buddy and correct me if i m wrong with the question
Cheers @dwkot

1 Like

Yes, I have done this already. The issue is that there is no information being returned from the variable of type mailMessage when I call .Body on it. All it returns is an empty string,

Hey @dwkot,

Can you attach your workflow here?Let me check.

Fine
No worries
you were almost done @dwkot
–kindly check with the properties in the get outlook mail activity like onlyunreadmail is enabled or not
if enabled we need to have atleast one or two unread mails
–then check with the TOP property in the property panel and it should be more than 2 or 3
–then enable the markasread property as well

Cheers @dwkot

Thanks for your help so far! While I had already done the steps you recommended, I don’t think this is an issue with the Get Outlook Mail Messages call not returning anything, because I can access the subjects of the emails being returned by Get Outlook MailMessages, which leads me to believe that UiPath is returning a list of something from this call, but for whatever reason, the body property (and other properties) of the emails being returned are not being set, or are being set to null. Let me clarify in case it wasn’t clear earlier - I can call .Subject in my workflow on the emails being returned by Get Outlook Mail Messages and the result matches the subject of the emails I am interested in, so the call is returning emails, and the emails I want it to. However, when I call .Body on these emails, it only returns an empty string, which doesn’t make much sense because I know the body of the email should have some information in it.

1 Like

Fine, then it must be a package issue
–lets do one thing, kindly uninstall the uipath.mail.activities in the studio by going to
manage packages in design tab -> search in project dependencies -> uninstall uipath.Mail.Activities and reinstall it and close the studio and reopen it again and try buddy
or
–if still issue exists, uninstall the uipath studio and reinstall it, might work as some package installation might be missing
or
–restart the outlook application by closing the process in task manager and reopen the outlook applicatin

hope this would work for sure, lets try buddy
Cheers @dwkot

1 Like

Hey @dwkot,

Please try item.Headers(“PlainText”) and see if this returns anything.

Give it a try once and do let me know if it works.

Hi! I’ve tried this before - headers are stored in the email object as a collection of name value pairs, where the name (like “plaintext”) is mapped to a corresponding value (in the case of plaintext, to the plaintext content of the email)… For some emails, the “plaintext” header is present, and with it, the content of the email body. Unfortunately, the only headers contained in my email are “uid”, “date”, “date created”, and “date received”, none of which are mapped to the body content of the email I am interested in. Trying to use item.Headers(“PlainText”) just returns a blank string in my case.

I tried these, but didn’t have much luck :frowning:

1 Like

Hey @dwkot
mail.Headers(“HTMLBody”)

have you tried this also?

oh
Strange,
So ony thing left is do we really have any body content in the mail that we fetch
Kindly check that once buddy

Cheers @dwkot

Yes, I have. The only Headers present for my email are “uid”, “date”, “date created”, and “date received” (I found this out by iterating over the elements of the Headers attribute of the email using a foreach loop). Using any other header, such as “plaintext” or “HTMLBody” or “randomHeader”, is just going to return a blank string, because those headers aren’t included in the collection.

Yes, there should be content in the body of the emails, as I made them myself :slight_smile: In order to check that it wasn’t just me making a small mistake, I also chose some random emails out of my inbox, and the bodies of those were not returned either.

This ended up being a security issue with my Outlook. I still haven’t solved it yet, but since this isn’t a UiPath issue, I’m going to mark it as resolved.

UPDATE: I solved this problem by making an Outlook macro to save the emails as txt files, and then just opening them using uipath. This is a good workaround for people who need to access email content from outlook with robust security settings.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.