Problem when reading outlook messages as plain text

Hi All,
I am using get outlook message activity in my code where i am getting First top 1 mail on behalf of some filter.And then reading mail body as string and comparing this body text with some regex patterns and process further.

Now problem which i am getting is that, mail has multiple lines. When i am seeing it in local window variable. it has \r \n … these characters available. I tried it replacing with “” (blank string) which is also not working. Can any one suggest what i need to do for reading mail as a plain text without theses special character.

We can store that mail body to a string variable like this
Inside the FOR EACH loop where the mailmessage list variable from Get Outlook mail activity is passed as input with TYPE ARGUMENT as System.Net.Mail.MailMessage

—inside the loop use a ASSIGN activity like this
str_input = item.Body.ToString
Where item is the variable from FOR EACH activity

Now this str_input variable can be used for string manipulation

To remove blank lines in the string then use this expression
str_output = String.Join(Environment.NewLine,str_input.Split(Environment.NewLine.ToArray(),Stringsplitoptions.RemoveEmptyEntries))

Cheers @Techypanduit

1 Like


it has \r \n …

\r and \n in locals panel are defined as the following.

\r :  same as   vbCr  or Chr(13)
\n:  same as vbLf or Chr(10)
\r\n : same as vbCrLf or Chr(13)&Chr(10)

For example, if you want to replace \r (at locals panel) to “”, you can write as the following.

If you want to replace \r\n (at locals panel) to “”, you can write as the following.

Hope this helps you.


1 Like

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