Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Micros Res 3700 report mailer

Status
Not open for further replies.

Crespo

IS-IT--Management
May 8, 2019
13
0
0
UG
Hello,just wondering if anyone here can help me with a mailer i can use to send out daily reports automatically from micros res 3700 v5.6. thanks in advance.

 
sure, here's a powershell script I wrote a while back. the smtp stuff at the bottom is depreciated but is still functional as of this post. it may break in the future. we've been using google's smtp server, if you use their smtp server as well you'll need to use an app password for $Password and not the main password. run this script as a windows scheduled task.

code is provided as is, no support, use at own risk, etc etc. feel free to edit as needed but please do not remove the first four commented lines, thank you.

Code:
# micros report emailer version 2.0
# no blat, no stunnel, powershell only
# final destination
# written by mcuiffi@proton.me

# directory and file naming
# yesterday calculates yesterday's date and formats it to not have any spaces
# shouldn't need to change this one
#
# rptpath is the directory that micros uses to generate reports to pdfs, with a wildcard to grab all pdfs in that folder
# example: "C:\PDFReports\*.pdf"
#
# zippath is the directory for compressing all the report pdfs into a zip file
# example: "D:\Emailer\archives"
#
# zipname is the name of the zip that's created, add the name before the $yesterday variable
# example: "Micros_CC_$yesterday"

$yesterday = (Get-Date).AddDays(-1).ToString('MM-dd-yyyy')
$rptpath = "D:\ReportEmailer\*.pdf"
$zippath = "D:\ReportEmailer\archives"
$zipname = "EOD Reports $yesterday"
Compress-Archive -Path $rptpath -DestinationPath "$zippath$zipname"

# Sender and Recipient Info

$MailFrom = ""
$MailTo = ""

# CC Info
# if multiple recipients are needed, you can configure them here
# not sure how to put them all in one variable yet so if more than one cc is needed, you can duplicate the line and increment the variable name
# just make sure to delete the # at the start of the line

#$MailCC1 = "cc email 1 address here"
#$MailCC2 = "cc email 2 address here"
#$MailCC3 = "cc email 3 address here"
#and so on


# Sender Credentials

$Username = ""
$Password = ""

# Server Info

$SmtpServer = "smtp.gmail.com"
$SmtpPort = "587"

# Message stuff
# same thing with using cc here, duplicate lines and delete # as needed

$MessageSubject = "Daily EOD Reports $yesterday" 
$Message = New-Object System.Net.Mail.MailMessage $MailFrom,$MailTo
$Message.Subject = $MessageSubject
#$Message.cc.Add($MailCC1)
#$Message.cc.Add($MailCC2)
#$Message.cc.Add($MailCC3)
#and so on
$Message.Attachments.Add("$zippath$zipname.zip")

# Construct the SMTP client object, credentials, and send
# basically don't worry about this block at all

$Smtp = New-Object Net.Mail.SmtpClient($SmtpServer,$SmtpPort)
$Smtp.EnableSsl = $true
$Smtp.Credentials = New-Object System.Net.NetworkCredential($Username,$Password)
$Smtp.Send($Message)

Remove-Item D:\ReportEmailer\*.pdf
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top