I created a workflow wherein bot reads the excel data and then created a loop for each row.
How could I:
- Read the excel column and write sender’s name dynamically in “to” of “send outlook mail message” activity?
- 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.
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.
- Read the whole data to a data table using Read Range Activity.
- Use For each row activity and read in loop.
- Assign to variables the fields by row index.
- Attach email app(outlook) then use selectors for the To,Subject and message fields.
- 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.
Main.xaml (17.4 KB)
Hi, @jibanjyoti: I actually started with that only. There are 3 challenges with this approach:
- I have 17 columns and 15+ rows. I would need to add row(1) + row(2) +…row(17) in mail body
- The tabular format of row added is not preserved
- 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.
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-
Mail.zip (10.8 KB)
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)
For converting Excel datatable into a table in body of email, you can try this out:
- Read the datatable ie dt.
- Count the rows and columns of the datatable → dt.rows.count and dt.columns.count.
- 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).
- Create a dynamic table using tag with the datatable content. → use for each activity and append line to the .html file.
- close the html tags.
- send the html file as body in the Outlook mail activity. (click on ishtml check box)
Thanks. It helped me to derive a solution.
Hello Igul, do you mind to share?
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.
Thank you so much…
You make my day
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.
Above code work for me very well. @harjyot123 please share your xaml
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
Hi @harjyot123, Install and use this package,
to convert your datatable to a html.
Hi @akhi_s27 - I Used this code but it gives me datatable with all Headers and tags in it !
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?