Creating an Outlook/Thunderbird Draft Email including Attachments
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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:
- MIME-Version: 1.0: Just keep this
- X-Unsent: 1: This line will make sure the file be opened in your email client in Edit mode. I have tested it in Outlook and it works. If you want this to work in Thunderbird, you will need to install this fix.
- To: This is the To email address you want the Draft email to pre-populate. This is usually a list of target report recipients.
- Subject: This is the Subject you want the Draft email to pre-populate.
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:
- Empty lines are important in the eml file. However, when you use the Summation tool to concatenate the strings, it removes empty lines. You will need to replace the place holder [BLANK LINE] near the end of the workflow.
- When you use the Summation tool to concatenate the strings, make sure you specify \r\n as Separator. It is the carriage return line feed.
- In the Blob Convert tool, select Convert from a Blob Field, and select Convert to Base64 encoding Binary Data
- In the Output Data configuration, just output as a Comma Separated Value file but you are going to specify a filename with *.eml ending, such as DraftEmail.eml. That's the file you will attach in the Alteryx workflow and send to yourself for final checking.
- In the Output Data configuration, make sure you put Never in the Quote Output Fields.
Please leave any comments below if you have any insight/feedback, and I will try to answer them, thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi Kelvin.
Thank you for this brilliant idea! It indeed is very helpful.
1 question though, can dynamic email body be included in this eml?
Since data source differs from day to day, sometimes I will need to send out the email, sometimes don't.
Also, my Alteryx workflow produces report based on conditions, for example:
Company Name | Payment Date | Payment Amount | Email Address |
A | 1/1/2020 | USD 1000 | a@a.com |
A | 1/3/2020 | USD 2000 | a@a.com |
B | 2/2/2020 | USD 2000 | b@b.com |
C | 1/1/2020 | USD 1000 | c@c.com |
C | 3/4/2020 | USD 1000 | c@c.com |
C | 2/5/2020 | USD 3000 | c@c.com |
and I am trying to achieve something like this:
1) To: anyone@anyone.com <----how should I code this so that the recipient is being picked up for respective company?
2) Email body also includes the table of payment details, is it possible to be included in the eml?
Appreciate if you could provide some opinions to this. Thank you very much!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I think it is possible. You will need to format the table as HTML and put into the eml file, which is quite tricky. Let me know if you found a solution. Thanks for your question and feedback.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
When I coped over this workflow and applied it using my information, everything worked with the exception of the excel attachment. At first glance the file name and type appears accurate, however when I go to open the Excel I am met with an error message:
"Excel cannot open the file 'sample.xlsx' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file"
What could be driving this issue, and which component of the workflow I would review to make changes?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thank you for this demo and construction template. I have found it valuable in our workspace.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Can you post a sample workflow so I can take a look?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi Kelvin,
thank you for this brilliant method of draft email creation, it has been very helpful!
Had a related exercise that I would appreciate your thoughts on
If outlook emails are being saved in a folder or SharePoint list, is there a capability for Alteryx to pick up the email from the folder/SharePoint and send an email as a "Reply To" operation; essentially continuing the email thread?
So instead of attaching the previous email to the new draft email, is there a way that the previous email thread can be included in the body of the new draft email? I am new to HTTP requests, so would be grateful for your help on this
Thank you!
Ritesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi Kelvin,
Notice this workflow and it's a really helpful. I just want to ask is there a way to fill in the "Cc:" field of an email as well
Thanks
Jon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi Jon, I made it adding CC to the email by simply inserting a new row between rows "To: ... " and "Subject:..." of the very first Text Input Tool
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
hi,
could you please help me with "Cc" coding and also "From" if possible
