Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Email Batch Macro With Varying # of Attachments

FFFool
9 - Comet

We have a process that we are building that will have a variable number of attachments in an email tool. There will be some emails going out with 5 attachments, some with none. What I'm trying to do is create a batch macro that takes the full input, as well as a control input with Invoice # and # of attachments, and using the # of attachments as the control parameter. I believe this is working properly. 

 

The issue I'm having is when I get to the actions on the email tool. For my test, I've added 3 attachments to the Tool in the macro and am trying to say if the Control Parameter only = 2, then Make Attachment 1 and 2 = True and Attachment 3 = False, which I assumed would stop the tool from trying to send Attachment 3. I have 3 separate actions, each one referring to the Attachments>Attachment([name])>ValueIsField and highlighted the @value - value="True" line within the action tool. I then used the Formula ToNumber([#1])>=1, >=2. >=3 for the 3 attachments respectively. 

 

I've tried a few different formulas as well, but every time I get 'Invalid Path: "3" in MakeCleanPath()' for my first record because there is only 2 attachments and it still appears to be trying to find the 3rd attachment. Has anyone had any success at dynamically adding, removing, or changing the number of attachments based on an action? I would like to make the default have 10 attachments and then set them to false using action tools if there is no data in the corresponding fields. 

 

EDIT: After converting to a standard macro for testing, it appears the value I'm changing to false does not delete the attachment, but rather changes the checkbox that states whether you are using a field vs. browsing to a file in the setup. So, it is looking for  a file path of '3' when it is successful at changing the value listed above. I don't believe it is possible to change whether or not there actually is an attachment using the Action tool at this time. Someone please tell me if I'm wrong. 

18 REPLIES 18
kgiuliani
6 - Meteoroid

Thank you very much for the response! This is working great, except I'm having trouble understanding one piece - toward the end of the workflow, there's a text input tool - I added a few more rows of data to it with different Subject values (Subject1, Subject2, Subject3, Subject4 & Subject5 - i.e., unique values for each of the 5 emails). When I run the workflow, 25 emails are generated instead of 5 emails. Any suggestions on how to limit to 5 emails? I tried adding various tools (sample, unique, summarize) after the subsequent join without success. I'm fairly new to Alteryx, so I may be missing something simple! Thanks again for your help, greatly appreciated!

Claje
14 - Magnetar

Hi,

 

The trick here is something I didn't set up in my example.  On the macro in the workflow, there is a "Group By" tab - you should pick the "EmailNumber" field in both the Control GroupBy and Input4 GroupBy field in this example workflow - this will batch the emails together so each set of files is sent out one at a time.

 

claje_emailbatchconfig.PNG

 

I attached a revised example here that also updates the macro to fix the "Body" update formula to correctly update this location.

kgiuliani
6 - Meteoroid

That is exactly what I needed, thank you so much!

Pinaki
6 - Meteoroid

I am having an issue using this. 

BatchEmailAttachment (11) Record #1: Tool #2: Invalid Path: "1" in MakeCleanPath()

 

I am trying to use this to split my output into multiple files and attach them in a single email

 

clipboard_image_0.png

Pinaki
6 - Meteoroid

Please help regarding this.

ekarmanov
7 - Meteor

I had the privilege of meeting @Claje and @jdunkerley79 at Inspire Europe 2019 last week in London, and just wanted to relay my many thanks for the support I received from Jesse and James with this macro and workflow. Also, my many thanks to Hannah Keller of Alteryx who made the introduction and helped explain what these two geniuses worked up.

Cheers guys!

Biko
7 - Meteor

@Claje I think this is quite similar to my issue. It seems like I am stuck with how to input my client before the sample tool. 

 

https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Sending-emails-with-dynamic-number-of-...

rohan_tibarewala
9 - Comet

This was excellent. I got to learn a bit about 'update raw XML with formula' functionality with this and i feel it can come in handy in many more cases.

LukeDolman
6 - Meteoroid

In case it helps anyone I came up with a different solution that does not require a macro and can be used in any standard flow. Just to recap, I needed to send a varying number of attachments to several email recipients.

 

I used a Tile tool to generate unique numeric values for each recipient/file, using recipient as my unique column. I then used a formula tool to create a new column with values of 'File1, File2' etc. Then used a Cross Tab tool to create a single row per recipient with new columns of File1, File2 and so on, with the file names as values. I then added a filter tool with logic of "If File1 is not null and File2 is null" - true goes to an email tool with only one attachment of File1. The false connection goes to a second filter tool has logic of "If File2 is not null and File3 is null" - true goes to an email tool with two attachments, File1 & File2. False goes to a third filter tool.... and so on and so on. My flow goes out to 50, which will hopefully cover anything I'm likely to need.

 

There's also a Text Input tool creating 50 dummy File1, File2... columns, unioned with the above to give it a consistent 50 columns.

 

I don't have a sample of it, but if it helps anyone I can produce one. 

Labels
Top Solution Authors