Question: It is common to need an email sent as part of a custom command procedure. The solution presented here is the result of a need to replace MapiSend which Outlook security changes have made obsolete. Solution: The Visual Basic Script attached can be used to send emails from a custom command procedure.
Following is an example of how the VB script is executed:
| (call :sub070_email_reports) >> %joblog% 2>&1 || %x% :sub070_email_reports @echo **************************************************************** @echo sub070_email_reports @echo time /t (%AppDrive%:) (call �iDis%\%cmdproc%_dis.bat) (set fa=%emailAdmin%) (set mr=%distribution%) (set ms="%cmdProc% reports") (set mm="See attached files") (set mt="NA") (set ma1="%LoadRptfile%") (set ma2="�iTranslatorSummary%") (set ma3="�iTranslatorErrors%") (set ma4="�iUpdateEmPathReportfile%") (set smtp=mail.yourdomain.com) (cscript �iwsh%\aciSendMail.vbs �% %mr% %ms% %mm% %mt% %ma1% %ma2% %ma3% %ma4% %smtp% //B) (goto :eof) |
Note that the example shown uses several environment variables defined as follows:
- fa = From Address for example denton@AppliedConceptsHrPayroll.com
- mr = recipient(s) (multiples must be separated by ';' and
must not be ambiguous in default address book.) - ms = subject line
- mm = message to be placed in the email body
- mt = specifies text file for contents of the mail message
- ma1 - ma4 = attahments 1 through 4
- smtp = smtp server
Note that MM or MT must be set to NA for not applicable. Also, and of ma1-ma4 can be set to NA.
Note that other environment variables are client specific and could be anything of your choosing.
Note that the command procedure statements shown are a small portion of a larger command procedure. The approach shown places the email VB script in a subroutine. If you would like additional information on using subroutines and the logging of errors then I recommend you review knowledge article 50018- HOWTO: emPath Custom Command Procedures .