How to Send HTML Email using UiPath Studio?

In this post, we will send an email having an HTML body. This is useful if you want to send customized good-looking emails to your team or anyone.

Prerequisites

  1. UiPath Studio
  2. Outlook

Make sure you are logged in to the Outlook application. It is not necessary to keep the outlook open during the automation run.

Create a New Process

Open UiPath Studio, click on New Process. I will name this SendHTMLEmail. I have used the YouTube Terms of Service Change email and got its HTML code using Inspect.

Put the HTML code you want to send into a text file and place it somewhere on your local system.

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <link
      href="http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700|Montserrat"
      rel="stylesheet"
      type="text/css"
    />
    <link rel="stylesheet" type="text/css" href="css/style2.css" />
    <link rel="icon" href="favicon.png" type="image/x-icon" />
    <title>Hello World</title>
  </head>
  <body>
   <table
   align="center"
   border="0"
   cellpadding="0"
   cellspacing="0"
   role="presentation"
   style="
     background-position: center center;
     background-size: contain;
     background-repeat: no-repeat;
     width: 100%;
   "
 >
   <tbody>
     <tr>
       <td align="center">
         <div
           class="m_-751765892175219864mj-column-per-100"
           style="
             font-size: 0;
             text-align: left;
             direction: ltr;
             display: inline-block;
             vertical-align: top;
             width: 100%;
           "
         >
           <table
             border="0"
             cellpadding="0"
             cellspacing="0"
             role="presentation"
             width="100%"
           >
             <tbody>
               <tr>
                 <td style="border: none; vertical-align: top; padding: 0 0 0 0">
                   <table
                     border="0"
                     cellpadding="0"
                     cellspacing="0"
                     role="presentation"
                     width="100%"
                   >
                     <tbody>
                       <tr>
                         <td>
                           <table
                             width="100%"
                             role="presentation"
                             border="0"
                             cellpadding="0"
                             cellspacing="0"
                             style="table-layout: fixed"
                           >
                             <tbody>
                               <tr>
                                 <td
                                   align="left"
                                   valign="middle"
                                   style="
                                     overflow: hidden;
                                     min-width: 480px;
                                     max-width: 600px;
                                     padding: 0px 0px 0px 0px;
                                   "
                                 >
                                   <a
                                     href="#m_-751765892175219864_"
                                     style="
                                       display: block;
                                       width: 600px;
                                       height: 88px;
                                     "
                                     aria-hidden="true"
                                   >
                                     <img
                                       src="https://ci5.googleusercontent.com/proxy/0TleldWs3DSPmkALff-E0bXJXcVwN9qpcgT9wgGXbZPTVwaIXrbUkH8jdIY0HumFuqyp-eW1afisxKTUrzF3Dsm6ijmsdVGJloYcb0g-TGl6YsRRIQMnR3QyZBNFt3vqfPg7DD04=s0-d-e1-ft#https://www.gstatic.com/gumdrop/files/ytc-youtube-header-fill-w1200px-h176px-2x.png"
                                       width="600"
                                       height="88"
                                       title=""
                                       alt=""
                                       border="0"
                                       style="
                                         display: block;
                                         width: 600px;
                                         max-width: 600px;
                                       "
                                       class="CToWUd"
                                     />
                                   </a>
                                 </td>
                               </tr>
                             </tbody>
                           </table>
                         </td>
                       </tr>
                       <tr>
                         <td style="font-size: 0">
                           <div style="height: 16px">&nbsp;</div>
                         </td>
                       </tr>
                       <tr>
                         <td
                           align="left"
                           valign="top"
                           style="direction: ltr; padding: 0 24px 0 24px"
                         >
                           <p
                             style="
                               margin: 0;
                               padding: 0;
                               color: #131313;
                               font-family: Roboto, Arial, Helvetica, sans-serif;
                               font-size: 16px;
                               font-weight: 400;
                               line-height: 24px;
                               letter-spacing: 0.1px;
                             "
                           >
                             You’re receiving this email because we’re updating
                             the YouTube
                             <a
                               href="https://notifications.google.com/g/p/AD-FnEw6bks0XFQCuxioi789p4mt2Q3Y1QxGbqiZp7q6FCJwFlM_tnxDzxwV73kbRQ271qfmCnolaUz7FgEi2WGplzf_3geS4Y4BfpMP03I"
                               style="
                                 font-weight: bold;
                                 color: #065fd4;
                                 text-decoration: none;
                               "
                               target="_blank"
                               data-saferedirecturl="https://www.google.com/url?q=https://notifications.google.com/g/p/AD-FnEw6bks0XFQCuxioi789p4mt2Q3Y1QxGbqiZp7q6FCJwFlM_tnxDzxwV73kbRQ271qfmCnolaUz7FgEi2WGplzf_3geS4Y4BfpMP03I&amp;source=gmail&amp;ust=1621868107313000&amp;usg=AFQjCNHWTr3g38r02YkBqIxdY9oAmWvtfg"
                               >Terms of Service</a
                             >
                             (“Terms”) to clarify our terms and provide
                             transparency to our users. The Terms were similarly
                             updated in the United States in November 2020. These
                             changes shouldn't significantly alter your access or
                             use of the YouTube&nbsp;service.
                           </p>
                         </td>
                       </tr>
                       <tr>
                         <td style="font-size: 0">
                           <div style="height: 16px">&nbsp;</div>
                         </td>
                       </tr>
                       <tr>
                         <td
                           align="left"
                           valign="top"
                           style="direction: ltr; padding: 0 24px 0 24px"
                         >
                           <p
                             style="
                               margin: 0;
                               padding: 0;
                               color: #131313;
                               font-family: Roboto, Arial, Helvetica, sans-serif;
                               font-size: 16px;
                               font-weight: 400;
                               line-height: 24px;
                               letter-spacing: 0.1px;
                             "
                           >
                             A summary of the changes:
                           </p>
                         </td>
                       </tr>
                       <tr>
                         <td
                           align="left"
                           valign="top"
                           style="padding: 0 24px 0 24px; direction: ltr"
                         >
                           <ul
                             style="
                               direction: ltr;
                               margin-top: 0;
                               margin-bottom: 0;
                               padding: 0;
                               font-family: Roboto, Arial, Helvetica, sans-serif;
                               color: #131313;
                               font-size: 16px;
                               line-height: 24px;
                               margin-left: 24px;
                             "
                             type="disc"
                           >
                             <li style="margin-top: 14px; direction: ltr">
                               <strong>Facial recognition restrictions</strong>:
                               The Terms of Service already state that you cannot
                               collect any information that might identify a
                               person without their permission. While this has
                               always included facial recognition information,
                               the new Terms make that explicitly&nbsp;clear.
                             </li>
                             <li style="margin-top: 14px; direction: ltr">
                               <strong>YouTube’s right to monetize</strong>:
                               YouTube has the right to monetize all content on
                               the platform and ads may appear on videos from
                               channels not in the
                               YouTube&nbsp;Partner&nbsp;Program.
                             </li>
                             <li style="margin-top: 14px; direction: ltr">
                               <strong
                                 >Royalty payments and tax withholding</strong
                               >: For creators entitled to revenue payments, such
                               payments will be treated as royalties from a U.S.
                               tax perspective and Google will withhold taxes
                               where required by&nbsp;law.
                             </li>
                           </ul>
                         </td>
                       </tr>
                       <tr>
                         <td style="font-size: 0">
                           <div style="height: 16px">&nbsp;</div>
                         </td>
                       </tr>
                       <tr>
                         <td
                           align="left"
                           valign="top"
                           style="direction: ltr; padding: 0 24px 0 24px"
                         >
                           <p
                             style="
                               margin: 0;
                               padding: 0;
                               color: #131313;
                               font-family: Roboto, Arial, Helvetica, sans-serif;
                               font-size: 16px;
                               font-weight: 400;
                               line-height: 24px;
                               letter-spacing: 0.1px;
                             "
                           >
                             <strong
                               >Please make sure you read the updates to the
                               Terms carefully. The new
                               <a
                                 href="https://notifications.google.com/g/p/AD-FnEwXmJDGba8BKyRK7tWVP-skUCeVitzTj8J-9DNTQnWpNwHwxK0XuDA8yoU9QtnF5qc2lGNjFcIZP5_96UAFR-jgkm1BnmD95pJihDeIlQ"
                                 style="
                                   font-weight: bold;
                                   color: #065fd4;
                                   text-decoration: none;
                                 "
                                 target="_blank"
                                 data-saferedirecturl="https://www.google.com/url?q=https://notifications.google.com/g/p/AD-FnEwXmJDGba8BKyRK7tWVP-skUCeVitzTj8J-9DNTQnWpNwHwxK0XuDA8yoU9QtnF5qc2lGNjFcIZP5_96UAFR-jgkm1BnmD95pJihDeIlQ&amp;source=gmail&amp;ust=1621868107313000&amp;usg=AFQjCNESexBSfqlnPNfSnpMrqPYmuKEfVQ"
                                 >Terms</a
                               >
                               will take effect on June 1, 2021 for users outside
                               the U.S.</strong
                             >
                             By continuing to use YouTube after this date, you
                             are agreeing to the new Terms. Please note, if you
                             allow your child to use YouTube Kids, then you are
                             agreeing to the new Terms on behalf of your child as
                             well.
                           </p>
                         </td>
                       </tr>
                       <tr>
                         <td style="font-size: 0">
                           <div style="height: 16px">&nbsp;</div>
                         </td>
                       </tr>
                       <tr>
                         <td
                           align="left"
                           valign="top"
                           style="direction: ltr; padding: 0 24px 0 24px"
                         >
                           <p
                             style="
                               margin: 0;
                               padding: 0;
                               color: #131313;
                               font-family: Roboto, Arial, Helvetica, sans-serif;
                               font-size: 16px;
                               font-weight: 400;
                               line-height: 24px;
                               letter-spacing: 0.1px;
                             "
                           >
                             If you would like more information, visit our
                             <a
                               href="https://notifications.google.com/g/p/AD-FnEy6M2mbEeZSt-2j2xqxSeIC5yuqoV04hQ30lUsz22xXtKkHrScBbAIi2TEq0NMRyISC7pRuSUCXl6gEvH3DKpUlg3v0inIUg8eDP5Rio0Zj9dt-BrNJDY2rzA7ZfWsE8Id8_M_xOs4"
                               style="
                                 font-weight: bold;
                                 color: #065fd4;
                                 text-decoration: none;
                               "
                               target="_blank"
                               data-saferedirecturl="https://www.google.com/url?q=https://notifications.google.com/g/p/AD-FnEy6M2mbEeZSt-2j2xqxSeIC5yuqoV04hQ30lUsz22xXtKkHrScBbAIi2TEq0NMRyISC7pRuSUCXl6gEvH3DKpUlg3v0inIUg8eDP5Rio0Zj9dt-BrNJDY2rzA7ZfWsE8Id8_M_xOs4&amp;source=gmail&amp;ust=1621868107313000&amp;usg=AFQjCNFpF3D35px2TTv0_MCJuj03xX3dVQ"
                               >Help Center</a
                             >.
                           </p>
                         </td>
                       </tr>
                       <tr>
                         <td style="font-size: 0">
                           <div style="height: 24px">&nbsp;</div>
                         </td>
                       </tr>
                       <tr>
                         <td
                           align="center"
                           style="
                             font-size: 0;
                             padding-left: 24px;
                             padding-right: 24px;
                           "
                         >
                           <p
                             style="
                               border-top: 1px solid #ccc;
                               font-size: 1px;
                               margin: 0 auto;
                               width: 100%;
                             "
                           ></p>
                         </td>
                       </tr>
                       <tr>
                         <td style="font-size: 0">
                           <div style="height: 16px">&nbsp;</div>
                         </td>
                       </tr>
                       <tr>
                         <td style="font-size: 0">
                           <div style="height: 16px">&nbsp;</div>
                         </td>
                       </tr>
                       <tr>
                         <td
                           align="left"
                           valign="top"
                           style="direction: ltr; padding: 0 24px 0 24px"
                         >
                           <p
                             style="
                               margin: 0;
                               padding: 0;
                               color: #606060;
                               font-family: Roboto, Arial, Helvetica, sans-serif;
                               font-size: 12px;
                               font-weight: 400;
                               line-height: 18px;
                             "
                           >
                             You received this mandatory email service
                             announcement to update you about important changes
                             to the YouTube&nbsp;Terms.
                           </p>
                         </td>
                       </tr>
                       <tr>
                         <td style="font-size: 0">
                           <div style="height: 24px">&nbsp;</div>
                         </td>
                       </tr>
                       <tr>
                         <td
                           align="left"
                           valign="top"
                           style="padding: 0 24px 0 24px; direction: ltr"
                         >
                           <a
                             href="#m_-751765892175219864_"
                             style="display: block; width: 88px; height: 20px"
                             aria-hidden="true"
                             ><img
                               title=""
                               alt=""
                               src="https://ci3.googleusercontent.com/proxy/JO0izuqL0DciOmX_RZ9-1cP0BzeRvn_qZz6hboieW0V7Xrga4i00bAfEgscTlUW55tK49sTnec-fcdROwqZl3nelRthfcgjtp3l77LKQPf6jmd75hpD5k86AZXa_yCV73kv1gC_RpHoQ9h8=s0-d-e1-ft#https://www.gstatic.com/gumdrop/files/ytc-youtube-footer-transparent-w176px-h40px-2x.png"
                               height="auto"
                               width="88"
                               style="
                                 border: none;
                                 display: block;
                                 outline: none;
                                 text-decoration: none;
                                 width: 88px;
                                 height: 20px;
                               "
                               class="CToWUd"
                           /></a>
                         </td>
                       </tr>
                       <tr>
                         <td style="font-size: 0">
                           <div style="height: 24px">&nbsp;</div>
                         </td>
                       </tr>
                       <tr>
                         <td
                           align="left"
                           valign="top"
                           style="
                             padding: 0 24px 0 24px;
                             direction: ltr;
                             color: #606060;
                             font-family: Roboto, Arial, Helvetica, sans-serif;
                             font-size: 12px;
                             font-weight: 400;
                             line-height: 18px;
                           "
                         >
                           © 2021
                           <a
                             href="#m_-751765892175219864_"
                             style="
                               color: #606060;
                               font-family: Roboto, Arial, Helvetica, sans-serif;
                               font-size: 12px;
                               font-weight: 400;
                               line-height: 18px;
                               text-decoration: none;
                             "
                           >
                             Google LLC d/b/a YouTube, 901 Cherry Ave, San Bruno,
                             CA 94066
                           </a>
                         </td>
                       </tr>
                     </tbody>
                   </table>
                 </td>
               </tr>
             </tbody>
           </table>
         </div>
       </td>
     </tr>
   </tbody>
   <tbody></tbody>
 </table> 
  </body>
</html>
Microsoft365 for Business

Add a new activity Read Text File. Provide the HTML text file path to this.

In the properties section, create a new variable emailBody and save the output of the above activity into the variable.

Add a new Activity Send Outlook Mail Message. Provide the To address, Subject, and Body. The Body is the output variable created from the last activity.

In the properties panel, enter the Account email address from where the email is to be sent. Also, make sure to check the IsBodyHTML property.

The complete flow look like this.

Run the process and check your inbox for the email received.

Thank you All!!! Hope you find this useful.


Up ↑

%d bloggers like this: