Question

How to copy the excel table and paste in email body

  • 29 January 2024
  • 7 replies
  • 639 views

Badge +5

I want to get the table from an Excel and paste it in the same format in the email body.


7 replies

Userlevel 3
Badge +8

Hi @tayyabimtiaz1,

Please try the below steps to insert an Excel table into an email body:

  1. Retrieve the worksheet values and store them in a Table variable. You can do this by using the Excel advanced Get multiple cells action. Enter the same session name you used in the Excel advanced Open action and select All rows from the drop-down list. Create a Table variable using the icon to the right of the Assign to variable drop-down list.

  2. Instruct the bot to process the data row by row using the Loop action. Select the For each row in table iterator and select the same Table variable that you used in Get multiple cells. Create a Record variable using the icon to the right of the Assign to variable drop-down list. The Record variable holds all of the values for one row. With each iteration of the Loop, the bot retrieves the values of the next row and stores them in the Record variable, overwriting the values from the previous row.

  3. Use the Email body field to select one of the following format options for the body of the email:

    • Plain text: Use regular text in your email body, with no formatting effects, such as bold, italic, or underline, or special layout options.
    • HTML design: Use HTML script in your mail body when you want your content to be displayed in a certain layout every time. You can also include interactive elements, such as links.
    • HTML code: Use this option to create and customize your email layout and body. Use the editor toolbar to make various changes to your text, such as applying bold, italic, and other formatting effects, inserting links, and changing the font and size of the text. You can copy the content from the design editor and paste it in the Message field.
  4. Enter the content you want to send along with the email in the Message field. The email will be appended to the message you have specified.

For more details, you can refer to this documentation.

Thank you. 

Badge +5

Hi @tayyabimtiaz1,

Please try the below steps to insert an Excel table into an email body:

  1. Retrieve the worksheet values and store them in a Table variable. You can do this by using the Excel advanced Get multiple cells action. Enter the same session name you used in the Excel advanced Open action and select All rows from the drop-down list. Create a Table variable using the icon to the right of the Assign to variable drop-down list.

  2. Instruct the bot to process the data row by row using the Loop action. Select the For each row in table iterator and select the same Table variable that you used in Get multiple cells. Create a Record variable using the icon to the right of the Assign to variable drop-down list. The Record variable holds all of the values for one row. With each iteration of the Loop, the bot retrieves the values of the next row and stores them in the Record variable, overwriting the values from the previous row.

  3. Use the Email body field to select one of the following format options for the body of the email:

    • Plain text: Use regular text in your email body, with no formatting effects, such as bold, italic, or underline, or special layout options.
    • HTML design: Use HTML script in your mail body when you want your content to be displayed in a certain layout every time. You can also include interactive elements, such as links.
    • HTML code: Use this option to create and customize your email layout and body. Use the editor toolbar to make various changes to your text, such as applying bold, italic, and other formatting effects, inserting links, and changing the font and size of the text. You can copy the content from the design editor and paste it in the Message field.
  4. Enter the content you want to send along with the email in the Message field. The email will be appended to the message you have specified.

For more details, you can refer to this documentation.

Thank you. 

But in this way it can't get the table headers, I need the headers as well in the email body.

Userlevel 4
Badge +14

Hi @tayyabimtiaz1

You can uncheck the sheet contains header and then read the excel to get the headers.

 
Badge +5

Hi @tayyabimtiaz1

You can uncheck the sheet contains header and then read the excel to get the headers.

 

Still not getting the headers and it throws an exception.

Userlevel 4
Badge +14

Hi @tayyabimtiaz1

You can uncheck the sheet contains header and then read the excel to get the headers.

 

Still not getting the headers and it throws an exception.

Can you please share the logic and exception that you are getting

Badge +5

Hi @tayyabimtiaz1

You can uncheck the sheet contains header and then read the excel to get the headers.

 

Still not getting the headers and it throws an exception.

Can you please share the logic and exception that you are getting

I have unchecked the “contains header” option but it throws me an exception. In catch option, i have set a msg box when I run the bot it opens the from catch. attached image is for reference

 

Userlevel 4
Badge +14

@tayyabimtiaz1 , might be because of early increment of counter variable, please increment it at the end of the loop and test it. Also keep the sheet contains headers unchecked.

Reply