For many times, you want Alteryx to process some data, generate a report, and send to a group of recipients. However, you cannot really trust Alteryx to send directly to recipients because you want to check the report for the last time before it gets dispatched. If Alteryx is going to just generate the report and send to yourself, then you will have to manually forward the email, insert the recipients, remove ”FW: ” from the subject, and clean up the email header of the email body. These manual steps kind of of defeats the purpose of automation.
In this tutorial I'm going to share with you how to ask Alteryx to send you a Draft email. That is, an email with the ultimate recipients, Subject and email body already populated for you. It even attaches the newly generated reports that you want to send to recipients. After you receive the email from Alteryx, you can open up the Draft email, review and click send. Below is a sample output:
Now, to do this, you need to know a little bit of a file format called an eml file. An eml file is a text file with file name ended with eml. The content of the text file is similar to below:
MIME-Version: 1.0
X-Unsent: 1
To: anyone@anyone.com
Subject: Draft Email with Attachment
Content-Type: multipart/mixed; boundary="email_boundary"
--email_boundary
Content-Type: multipart/alternative; boundary="html_boundary"
--html_boundary
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
This is an HTML message. Please use an HTML capable mail program to read
this message.
--html_boundary
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<html><body>This is an email with <b>attachments</b></body></html>
--html_boundary--
--email_boundary
Content-Type: application/pdf; name="pdf_attachment.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="pdf_attachment.pdf"
[A base 64 encoding of an pdf attachment]
--email_boundary
Content-Type: application/vnd.ms-excel; name="excel_attachment.xlsx"
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename="excel_attachment.xlsx"
[A base 64 encoding of an Excel attachment]
--email_boundary--
Here are the description of some key fields:
Now, the boundary lines are more difficult to explain. Basically, you need to declare a boundary and describe what you are including. In my example, I'm including an HTML message, and two attachments. Just look at the sample eml message above and you should get a good idea of how to use the boundary.
Then, the most tricky part is, you want to include the attachments. You may use Alteryx to generate the reports, and the reports can be PDF, or Excel, or a picture, or a Word document or any file type. I'm going to attached a PDF file and an Excel file in the Draft email. In the declaration, you are going to specify Content-Type of each attachment. That basically tells your operation system what program to use when the recipient double-clicks on each of the attachment.
Now, the most interesting part is how you would encode the attachments in the eml message. Alteryx has these very interesting tools just for this purpose: the Blob Input and Blob Convert. You can make use of these to read your PDF file, convert to base64 text, and include in the Draft email.
Several things to watch out for when you configure the Alteryx workflow:
Please leave any comments below if you have any insight/feedback, and I will try to answer them, thanks.
Hi agnieszka_fatla77,
Were you able to solve the issue?
Do we have an option to have draft and body line in other language like German, French or Japanese. Subject line and Body Line is static its just that its not in English
Hey mate. Were you able to create this?
Thanks @suyunn
@ShaileshDevadiga @Yuk_Sha @sgaryali @agnieszka_fatla77
I was able to create boarder and table.
<html>
<head>
<style>
table, th, td {border: 2px solid BLACK ;border-collapse: collapse;}
</style>
</head>
<body>
<table><tr><th>First Name</th><th>Last name</th></tr></table>This is an email with test <b>attachments</b>
</body>
</html>
:)
Hi,
I am trying to change the font style and size, so leveraging html
Tried <html><body><p style = "font-family:'Arial'"><p style ="font-size:10px"></p></p></body></html>
but in eml it show different style and size as 11
is this logic working in eml
@AmitojSingh - Yes you can
Replace bodyline with below
--html_boundary
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
[BLANK LINE]
<html><body><p>"Please find attached the report for the day"</p><p>"Thank You and regards<br>"Amitoj Singh</br><CFS Ltd</br><br> 21 Ample Avenue</br></p></b></body></html>
[BLANK LINE]
--html_boundary--
[BLANK LINE]
There is something wrong with the workflow.
When I applied more complex html code the email has no colours and formatting is not applied.
Also I've just started re-building the workflow to make it a real example (dynamic recipients, cc, subject, dynamic files and content) and it is just crazy how many steps you have to follow to create the simplest, real email. It's better to switch to Python instead.
Thank you for this Solution. Is there a way to attach an image to body of the email. If Yes, can you help how can it be acheived?
Hi Kelvin, really appreciate your idea of saving draft. However, is there any methods of creating BCC into the process? Can you give a help on it? Thanks a lot!
Hello,
I also have similar kind of requirement, and tried lot of things, got few successes but Im not getting the a properly formatted table in the output eml files. The table data gets distorted and it comes line by line in the output.
If you have got a solution for this please let us know.
Best Regards,
Dhanvin Mehta