How to write excel data in outlook mail?

excel
email

#1

I created a workflow wherein bot reads the excel data and then created a loop for each row.

How could I:

  1. Read the excel column and write sender’s name dynamically in “to” of “send outlook mail message” activity?
  2. copy excel sheet header and a row in the outlook mail “body” and send to multiple users (each row to each user+ header which is common for all)
    Please suggest some code which could convert the datatable to string such as its tabular format is not lost. Also, Screen scraping or copy is not working for that excel sheet.

#2

Hi @igul,
Try this solution and change according to yours.
Just change the fields as per your column index and i have used outlook here. This is just a rough solution you can try exceptions and make the code more reliable.

How to:

  1. Read the whole data to a data table using Read Range Activity.
  2. Use For each row activity and read in loop.
  3. Assign to variables the fields by row index.
  4. Attach email app(outlook) then use selectors for the To,Subject and message fields.
  5. Type Into and click on send.

Note: Just check the property Add Headers while using Read Range activity otherwise first the header will be coming.

Hope this helpes. :slight_smile:

Main.xaml (17.4 KB)


#3

Hi, @jibanjyoti: I actually started with that only. There are 3 challenges with this approach:

  1. I have 17 columns and 15+ rows. I would need to add row(1) + row(2) +…row(17) in mail body
  2. The tabular format of row added is not preserved
  3. header row (common) also needs to be added in the body of each mail (15 rows of excel basically). As a workaround, I tried adding another activity “read row/ read range” to handle header row. But converting data table to string is not working

Could you please suggest an approach wherein I could preserve the tabular format of rows in mail body and add a header row to be sent to each recipient?
Also, I am using “send outlook mail message” activity to handle sending mails.


#4

Hello there,

So you are trying to paste a data table into the actual body, huh? try this one out, it reads the table and save the structure.-

another method it will be to simulate the copy and paste directly from excel-

please reply.

Mail.zip (10.8 KB)


#5

Hi,

Thanks for sharing it.
It acted as a workaround but still did not preserve the table structure as is. Attached the screenshot (email.jpg) for reference. It got further distorted in case of excel sheet I am referring since the column width is larger in it.
Also, Currently, it is sending entire data to each recipient.

I updated the script referring yours. Could you please further build on it?
In summary, I need to send entire row 2+ header to recipient 1, row 3+ header to recipient 3 -----row 15 + header while retaining the table structure.
Mail.zip (71.4 KB)


#6

Hi all,

For converting Excel datatable into a table in body of email, you can try this out:

  1. Read the datatable ie dt.
  2. Count the rows and columns of the datatable -> dt.rows.count and dt.columns.count.
  3. Create a html document with a table open tag using uipath (use activity write/append line to create a .html file and append the lines).
  4. Create a dynamic table using tag with the datatable content. -> use for each activity and append line to the .html file.
  5. close the html tags.
  6. send the html file as body in the Outlook mail activity. (click on ishtml check box)
  7. Thank you
    Nitin Safaya


Send excel values as table
#7

Thanks. It helped me to derive a solution.


#8

Hello Igul, do you mind to share? :slight_smile:


#9

Hi @beesheep,

I have referred to the sequence attached in the reply 5d ago (which is on the similar lines as suggested by you). Only change I made is adding html tags

etc. in the assign activities (already added in the sequence). Finally, clicked on ishtml check box in send mail activity.

#10

Hi,

Do you have any example for this one ?

Thank you


Send Outlook Message with DataTable as Body
#11

Please find the sample solution
New folder.zip (9.2 KB)


How to send Excel cells in the body of an outlook email instead of adding attachment?
How to pass data table in email without headers
How to write the contents of excel into email message body without loosing table formats
Table format as body in mail( not fetching table data from any file)
#12

Thank you so much…:slight_smile:
You make my day :slight_smile:


#13

can someone please share a better example for this?

I want to add the html table within an outlook template. I can use the above code to derive the html table, but having issues while using it within the template.


#14

Above code work for me very well. @harjyot123 please share your xaml


#15

Hello @Dill, @aksh1yadav , @Dominic, @Laxman_Pratap

Could you please help me to add the HTML data table within the Outlook template.

New folder.zip (19.0 KB)

I want to embed the table within any template. (Include signature as well)

Need help asap. Thanks and appreciate all the hard help :wink:


#16

Hi @harjyot123, Install and use this package,

to convert your datatable to a html.


#17

Hi @akhi_s27 - I Used this code but it gives me datatable with all Headers and tags in it !


#18

Hi @akhi_s27,

I used the above code, but my data table has a column of hyperlinks.

These hyperlinks are being sent in the mail as a simple string and not as hyperlink.

Can you help me fix this issue?