Unable to get the text message from the mail

Hello,
I am trying to get the text message from the the mail, but i get nothing when use this --> mail.Body (mail.Body.toString) and I am sure that there is a text message.
but mail.From.Address, mail.Subject- works fine.
Maybe i am using wrong method?
Please help.

Hello, can you share a screenshot of the sequence or upload the xaml so that we can have a look.
you should ideally be able to get the Body.

1 Like

Main.xaml (6.5 KB)

I also found that everything is working fine on another machine.

Try reinstalling all the packages in the workflow you are using.

1 Like

Hi @yaniketz,

You are getting a blank mail body may be because it’s in html format, other than plain text.
If so, read the html mail body by mail.Headers("HTMLBody") and convert it to plain text using the regular expression, System.Text.RegularExpressions.Regex.Replace(mail.Headers("HTMLBody"),"(<.*?>)|({.*})","") or you can use the key mail.Headers("PlainText") .

Please have a look at the workflow. HTML_to_plaintext.xaml (7.1 KB)

Warm regards,
Nimin

3 Likes

Thank you!

Can you also explain how correctky iterate through mail.Headers collection (return System.Collections.Specialized.NameValueCollection).
I want to see all keys.

When I am trying to use TypeArgument System.Collections.Generic.keyValuePair<String,String> I get System.InvalidCastException: Specified cast is not valid.

Hi @yaniketz,

You can iterate through mail header collection by,
Assign String_Array, header_collection= mail.Headers.AllKeys
Inside a for each loop, iterate through each keys(object) in header_collection and you can get the key values by mail.Headers(keys.ToString) .

Warm regards,
Nimin

1 Like

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