Ok, so because the email tool doesn't include authentication I've been forced to write my own email workaround
- I have a workflow that spits out a report in HTML
- I wrote an EXE that takes in the HTML (with inline images) and processes it to be the body of the email, and finally sends the message
It looks like the run command can't accept an input string as a command for example:
SMTP_Command.exe "From@email.com" "To@email.com" "subject"
So I have my workflow outputting the appropriate string to a batch file and I'm trying to open that.
But now I'm even confused as to how I can run this batch file. I absolutely can't wrap my head around Write source, read source, etc. I just want to write this string to a command line and be done with it. No matter what I try I get some type of error that and input or output needs to be configured.
Thanks everyone!
Side note: alteryx please fix the email tool, this is a ridiculous amount of side work to be doing just because you didn't include SMTP authentication.
Solved! Go to Solution.
Authentication is something we'd all like to see! add your two cents to these posts: https://community.alteryx.com/t5/Alteryx-Product-Ideas/Authenticate-Tool-SMTP-Address/idi-p/1740
As far as just running a basic batch file from the command tool, this works:
This was just a simple batch file: ECHO Hello; PAUSE;
You can pass arguments into it by using the command arguments option. I have a few of these inside batch macros so that I can pass the arguments in as control inputs.
The Write Source option allows you to take the data stream coming into the Run Command and write it to a file (so that whatever you end up running can use this data and you can ensure that it exists prior to running the command). This is a required option if you have data coming into the Run Command.
Read Results is for the opposite case, where whatever command you are executing create some sort of results file. You use the Read Results option to grab this results file and bring it back into the data stream for down stream processing. Read results is required if your run command output is connected to a downstream tool. Hope this helps!
So this is the batch file I'm trying to execute. Since it's sending an email I don't need to read in anything else, this is the end of the line.
The problem is my arguments are email sender, email receiver, and subject. From what I can tell I can't use variables to define the arguments in the run command tool. So I have a formula create the string I want to run in the command prompt and outputs it to a .bat file. Now all I have to do is open that batch file and I'm done.
I still get an error "Either an Output connection or Input connection is required.
To get rid of that error, hook the input of your Run Command to the end of your data stream, then set the Write Source to %temp%\temp.yxdb (basically just to satisfy the requirement that it is hooked to something, we'll output a file to the temporary file location).
Or use AdamR's method above (which is very elegant!) to create the batch file in stream, write it to the disk in Alteryx temporary storage, and then execute it.
I've decided that having used this technique three times in the Solution Center at the Inspire conference this year it is time for a CReW macro to run batch files.
Coming soon...
Thanks for the demo workflow. I get output when I run yours, but I'm trying to get it to work with my file paths but I get
"....sendMail.bat" returned an error code:1
When I copy and paste the string that's going into the batch file it works from the command line. So it's not my syntax there
Your command must not be returning 0.
Just add
exit 0
at the end of the batch file to force a 0 return
Still get the error when I add exit 0 to the end.
When I run the bat file from the command line it works perfectly (both ways, with exit 0 and without).
Oddly, it saves the file just fine (when I click the link it runs and I get my email)
User | Count |
---|---|
19 | |
15 | |
15 | |
8 | |
6 |