cancel
Showing results for 
Search instead for 
Did you mean: 

Format the body of outlook email.

SajaIsmael
Level 2
Hello,
I have just wanted to ask; if there is any way to format the long text of the body when I send it using
MS Outlook Email VBO::Send Email. 


------------------------------
Saja Ismael
------------------------------
10 REPLIES 10

PvD_SE
Level 12
Hi Saja,

While we do not have any formatting requirements, our emails do tend to have links as URL's and file locations that we need to be clickable by the recipient. Enclosing the URL or link in < and > will do that for you.

------------------------------
Happy coding!
---------------
Paul
Sweden
------------------------------
Happy coding!
Paul, Sweden
(By all means, do not mark this as the best answer!)

I just need to add new lines. How can we do that ?. I tried NewLine() function and it did not work.


------------------------------
Saja Ismael
------------------------------

I'd create a data item of typ Text and populate as follows:
-----------------------------------
"Hi!" & NewLine() & NewLine() & 
"text1 text1 text1 text1" & NewLine() &
"text2 text2 text2 text2" & NewLine() & NewLine() & 
"Kind regards," & NewLine() & 
"Saja Ismael"
-----------------------------------
which would result in:
-----------------------------------
Hi!

text1 text1 text1 text1
text2 text2 text2 text2

Kind regards,
Saja Ismael
-----------------------------------
Then you have the data item as input for your Send Email action.

------------------------------
Happy coding!
---------------
Paul
Sweden
------------------------------
Happy coding!
Paul, Sweden
(By all means, do not mark this as the best answer!)

...I recall one might be able to HTML format your text, but I do not use this myself.

------------------------------
Happy coding!
---------------
Paul
Sweden
------------------------------
Happy coding!
Paul, Sweden
(By all means, do not mark this as the best answer!)

In the MS Outlook Email VBO::Send Email. action emails are always HTML formatted !

<BR> is used to add a new line

Our mail body template for sending exceptions :


"<!DOCTYPE html>
<html>
<head>
  <meta charset='utf-8'>
  <style>
   table {border: 2px solid black; border-collapse: collapse; padding: 5px;}
   th {border: 1px solid black; border-collapse: collapse; padding: 5px; text-align: left; vertical-align: text-top; background-color: #92d050;}
   td {border: 1px solid black; border-collapse: collapse; padding: 5px; text-align: left; vertical-align: text-top;}
 </style>
</head>
<body>
  <p> The process stopped due to an exception, find more information below
  <BR> 
  <BR> Kinds regards
  <BR> Your favorite Robot !
</p>
  <table style='width: 100.0%'><tbody>
  <tr>
   <td style='width: 20%'><p><strong>Exception Type</strong></p></td>
   <td style='width: 80%'><p>"& ExceptionType() &"</p></td>
  </tr>
  <tr>
   <td style='width: 20%'><p><strong>Exception Stage</strong></p></td>
   <td style='width: 80%'><p>"& ExceptionStage() &"</p></td>
  </tr>
  <tr>
   <td style='width: 20%'><p><strong>Exception Detail</strong></p></td>
   <td style='width: 80%'><p>"& ExceptionDetail() &"</p></td>
  </tr>
 </tbody></table>
</body>
 
<footer>
 <p>
  <font color='#009900' face='Webdings' size='4'>P</font>
  <font color='#009900' face='verdana,arial,helvetica' size='2'>Please consider the environment before printing this email.</font>
 </p>
</footer>
</html>"

If you use a formatted text field you have to replace the NexLine() to <BR> :

<p>"& Replace( [Text]; NewLine(); "<BR>") &" </p>

If you want to insert a link to a file:
<p><a href='file:///" & [ScreenshotPath] & "'>Screenshot</a></p>



KevinWilson
Staff
Staff
Yes, You'll find that the Outlook VBO will recognize HTML formatting that is provided in the Email body.

Learned about that in a PoC we did about 4 years ago.

With that said, one is able to also build that HTML dynamically in terms of Table Rows, etc., which can be very useful.

Happy to send examples if that's helpful.


------------------------------
Kevin Wilson
`Solution Engineer
Blueprism
America/Denver
------------------------------

Hi,

I was looking exactly to build HTML dynamically email body in terms of Table Rows... can you send some examples?

Thanks in advance.

António


------------------------------
Antonio Melo
------------------------------

Hey Antonio, 

here is a tiny snippet I wrote in C# to convert a DataTable into an HTML table:

Input Argument being 'inCollection' (as Collection of Strings) and Output Argument being 'outHTML' as a text Data Item.
outHTML = "<table>";
        //add header row
        outHTML += "<tr>";
        for(int i=0;i<inCollection.Columns.Count;i++)
            outHTML+="<td>"+inCollection.Columns.ColumnName+"</td>";
        outHTML += "</tr>";
        //add rows
        for (int i = 0; i < inCollection.Rows.Count; i++)
        {
            outHTML += "<tr>";
            for (int j = 0; j< inCollection.Columns.Count; j++)
                outHTML += "<td>" + inCollection.Rows[j].ToString() + "</td>";
            outHTML += "</tr>";
        }
        outHTML += "</table>";​


------------------------------
Ramón Requena López
RPA Developer
Magenta Telekom
------------------------------

Hi Ramón,

Thanks for your reply. I was wondering if you had implemented some call to a template engine like https://shopify.github.io/liquid

Maybe compile it to an dll and include in global code functions.

So we can have a file template, the collection with data, and merge them into final HTML with an template engine.

This way I can change the email body, without changing the RPA code.

Thanks,
António


------------------------------
Antonio Melo
------------------------------