|Subject:||Send Uploaded Files Directly to Printer|
|Creation date:||7/29/21 4:17 PM|
|Last modified on:||7/30/21 8:58 AM|
Your office may have a printer that is designed to accept email attachments and print them out. You can use SynaMan to send uploaded files as attachments to that address automatically.
Setting up triggers on a Windows environment requires a few steps.
Step 1 is to create the powershell script that will actually send the email. Copy paste the contents below into a new script, such as “sendEmail.ps1”.
You will need to modify a few lines in the above code:
$outgoingUsername - This is the username to authenticate with your SMTP server
$outgoingPassword - This is the password for that username.
$outgoingServer - This is the smtp server address for your smtp server, such as smtp.google.com
$outgoingPortSMTP - This is the port number the SMTP server is listening on.
$outgoingToAddressList - This is the recipient email address of the printer.
$messageSubject - subject of the email.
$messageBody - body of the email.
You will notice that there is also this line:
$outgoingAttachmentURLList = @( $args )
This means that any file path that we pass into this command will be added as an attachment.
We now need to create a batch file that will run the powershell script we just created as well as give it the path for the file that was just uploaded.
Open notepad and paste the following content into the file:
Powershell.exe -executionpolicy remotesigned -File C:\pathToPowershellScript\sendEmail.ps1 %1
Modify the path to be the full path to the powershell script you created earlier.
Save the file as “sendEmail.bat”
For Linux machines, we can use the s-nail package since it let’s us specify external SMTP servers.
First, install s-nail:
$ sudo apt-get install s-nail
Next, we need to create a script that SynaMan will call in it’s trigger.
Let’s call this sendMail.sh, here are it’s contents:
$ echo "Message Body" | s-nail -v \
> -r "firstname.lastname@example.org" \
> -s "Subject" \
> -S smtp="mail.server.com:587" \
> -S smtp-use-starttls \
> -S smtp-auth=login \
> -S smtp-auth-user="email@example.com" \
> -S smtp-auth-password="Password" \
> -S ssl-verify=ignore \
Next, you need to modify the above code with your SMTP settings, including the body, recipient, and subject.
You’ll notice in the above code body there is a “$1” next to the attachment field. This is a command line argument that we will pass from SynaMan to the script. The remaining fields should be static, as the same user will be sending to the same recipient in all cases.
Once you've setup the appropriate scripts, the next step is to configure the trigger in SynaMan.
The following parameters must be specified:
Now, any time anyone uploads a file, SynaMan will call the batch file that will call the powershell script or the linux script and email your printer’s email address a copy of the file as an attachment.
Do you have a helpful tip related to this document that you'd like to share with other users?