Email Server IRIS as PrintBOS Destination EMAIL
Email Server IRIS as PrintBOS Destination EMAIL
This article outlines the dual support implemented for registering email information in PrintBOS and IRIS technologies, detailing their use cases, examples, and functionalities.
Supported Technologies
- PrintBOS Technology: Inserts email information into PrintBOS tables for legacy templates and scripts.
- IRIS Technology: Inserts email information into IRIS tables for modern templates and scripts.
Common Features
- Both technologies support CTE and Metadata.
- Both can function as a Mail Destination and are compatible with scripts.
PrintBOS Scripts for Email
@SetEmailMessage
Sets the body text of the email.
@AddEmailAddress
Adds an email address with the following parameters:
MailMetadataHandle:Uses the destination's handle if NULL.szCTEFileIn:Path to the CTE file.szEmailAddress:The email address.nEmailAddressType:Specifies address type: 0 – To, 1 – CC, 2 – BCC.
@AddEmailAttachmentFile
Adds an attachment file with the following parameters:
MailMetadataHandle:Uses the destination's handle if NULL.szCTEFileIn:Path to the CTE file.szAttachmentFileList:List of attached file paths (comma or semicolon delimited).bDeleteAfterSend:Specifies whether to delete files after sending.
Pending Considerations
- Addresses:
- Enable CC and BCC support in stored procedures.
- Ensure the ability to transfer lists of addresses from the engine.
- Attachments:
- Enable transferring lists of attached files from the engine.
- Validate the ability to send emails without attachments.
Examples
PBDesigner Examples
Configure the following options in the Input Tree:
- Email: To
- Email: CC
- Email: BCC
- Email: Attachment
- Email: Subject
- Email: Message
PB Script Examples
Static Script Example
#GLOBAL gEmailTo
#GLOBAL gEmailFrom
#GLOBAL gEmailSubject
#GLOBAL gEmailBody
gEmailTo = @GetInputFieldText("label.sEmailTo")
gEmailFrom = @GetInputFieldText("label.From")
gEmailSubject = @GetInputFieldText("label.sEmailSubject")
gEmailBody = @GetInputFieldText("label.sEmailMessage")
Global Script Example
#GLOBAL gEmailTo
#GLOBAL gEmailFrom
#GLOBAL gEmailSubject
#GLOBAL gEmailBody
newMessageID = @Guid()
SP= "[consist-iris].[dbo].[InsertNewMessage] @MessageID = '##MessageID##', @MessageBodyFile = '0', @From = '##From##', @To = '##sEmailTo##', @title=N'##sEmailSubject##', @MessageBody = '##sEmailMessage##', @FilePath= '##sAttachPath##', @FileTitle='##sFileTitle##', @JobID='##sJobID##', @ChannelID='##sChannelID##'"
SP = @Replace(SP,"##MessageID##",newMessageID)
SP = @Replace(SP,"##From##",gEmailFrom)
SP = @Replace(SP,"##sEmailTo##",gEmailTo)
SP = @Replace(SP,"##sAttachPath##","c:\kuku\test.pdf")
SP = @Replace(SP,"##sEmailMessage##","blyablya")
SP = @Replace(SP,"##sEmailSubject##",gEmailSubject)
SP = @Replace(SP,"##sFileTitle##","test.pdf")
SP = @Replace(SP,"##sJobID##","123")
SP = @Replace(SP,"##sChannelName##", "DefaultSMTP")
sConnectionString = "Driver={SQL Server};Server=localhost\SQLEXPRESS;Database=consist-iris;"
res=@ExecSql(sConnectionString ,SP)
End
Sending email using Script “After Close Job”
This article provides a comprehensive guide to integrating dual support for email registration using both PrintBOS and IRIS technologies. Below are the functionalities, examples, and pending considerations for enhancing email handling capabilities.
Example for Sending Email Using Script "After Close Job"
If the destination is "Output File," but after the job is executed, you need to send an email, follow these steps:
- Create an external script and assign it for this destination as "After Close Job".
- Generate the path to the CTE file. (There is no need to create this file—it will be created automatically.)
- Important!
- Specify the sender's technology in the script:
@AddEmailParameter(0, sCTEPathFile, "IRIS", "YES"). - Specify the email technology in the script:
@AddEmailParameter(0, sCTEPathFile, "CTE", "YES"). sCTEPathFilerefers to the path to the CTE file.
- Specify the sender's technology in the script:
- Add attached files using the function
@AddEmailAttachmentFile:@AddEmailAttachmentFile(0, sCTEPathFile, "C:\ARCHIVE\page1.PDF", bDeleteAfterSend)sCTEPathFile: Path to the CTE file.C:\ARCHIVE\page1.PDF: Path to the attachment file.bDeleteAfterSend: Flag indicating whether to delete the file after sending.
- Add email addresses (To, CC, BCC) using the function
@AddEmailAddress:@AddEmailAddress(0, sCTEPathFile, "[email protected]", 0)
sCTEPathFile: Path to the CTE file.[email protected]: Email address.0: Address type (0 – To, 1 – CC, 2 – BCC).
- Add email parameters using the function
@AddEmailParameter:@AddEmailParameter(0, sCTEPathFile, "Job/FileName", sJobID) @AddEmailParameter(0, sCTEPathFile, "UserName", sUserName) @AddEmailParameter(0, sCTEPathFile, "MessSubj", sSubject) @AddEmailParameter(0, sCTEPathFile, "Message", sFileContent)Job/FileName: Inserts the job file name.UserName: Inserts the username.MessSubj: Inserts the email subject.Message: Creates an HTML file for the message body (if sender is IRIS).- Alternatively, use
MAILBODYFILEto copy HTML content from a file.
- Send the email using the function
@SendEmail:@SendEmail(0, sCTEPathFile, 1)sCTEPathFile: Path to the CTE file.
Example Script
gEmail = "[email protected]" bHTMLCopyOnly = 0 //1 = only copy, without open/write html body file sUserName = Job.Username sJobID = Job.Filename sSubject = "טופס מרכז להפעלת eSIM" bDeleteAfterSend = 0 sEmail_Root = "C:\works\PBDigitalGit\Bin\Debug\Queue\Email" Ctepath = sEmail_Root + "\\" sCTEPathFile = Ctepath + "J" + @itoa(job.jobid) + ".cte" // Get Email sender type & Email Technology for restore mailsenderOld = job.emailsendertype mailtechnologyOld = job.emailtechnology // Set Email sender type & Email Technology @AddEmailParameter(0, sCTEPathFile, "IRIS", "YES") @AddEmailParameter(0, sCTEPathFile, "CTE", "YES") // Attach files @AddEmailAttachmentFile(0, sCTEPathFile, "C:\ARCHIVE\page1.PDF", bDeleteAfterSend) @AddEmailAttachmentFile(0, sCTEPathFile, "C:\ARCHIVE\page2.PDF", bDeleteAfterSend) // Set Email address To/CC/BCC @AddEmailAddress(0, sCTEPathFile, gEmail, 0) // 0 - To @AddEmailAddress(0, sCTEPathFile, "[email protected]", 0) // Add additional email parameters @AddEmailParameter(0, sCTEPathFile, "Job/FileName", sJobID) @AddEmailParameter(0, sCTEPathFile, "UserName", sUserName) @AddEmailParameter(0, sCTEPathFile, "MessSubj", sSubject) // Set Email body from File sSourceHTML = "C:\HTML\htmlbody.htm" if bHTMLCopyOnly = 1 Then GOTO 2000 fH = @OpenFile(sSourceHTML, 1) sFileContent = @ReadFile(fH, 80000) sFileContent = @Trim(sFileContent) @CloseFile(fH) @AddEmailParameter(0, sCTEPathFile, "Message", sFileContent) GOTO 3000 2000 // If NOT need change message body file content @AddEmailParameter(0, sCTEPathFile, "MAILBODYFILE", sSourceHTML) 3000 @AddEmailParameter(0, sCTEPathFile, "Status/Ready", "1") // Send Email - insert into IRIS DB @SendEmail(0, sCTEPathFile, 1) // Restore Email sender type & Email Technology job.emailsendertype = mailsenderOld job.emailtechnology = mailtechnologyOld End
Example for static HTM file:
0 THEN GOTO 10
GOTO 100
10
fileContent = @ReadFile(hFile, 10000)
@CloseFile(hFile )
strJobNumber = @itoa(job.jobid)
fileContent = @Replace(fileContent , "##JOBNUMBER##", strJobNumber)
@AddEmailParameter(0, "", "MAILBODY", fileContent) //for output fields only!!!
//@SetEmailMessage(fileContent) //for input fields only!!!!
100
end>
Example of script for send email with client HTM body – from PB Script:
sBody="Custom HTML..."
strJobNumber = @itoa(job.jobid)
sBody = @Replace(sBody , "##JOBNUMBER##", strJobNumber)
@AddEmailParameter(0, "", "MAILBODY", sBody) //for output fields only!!!
//@SetEmailMessage(sBody) //for input fields only!!!!
Conclusion
By leveraging the dual support of PrintBOS and IRIS technologies, email handling can be tailored for both legacy and modern templates. These functionalities ensure seamless integration and robust email delivery processes.
Using "After Close Job" scripts simplifies automating email sending with detailed customization for attachments, recipients, and message content. This approach ensures flexibility and seamless integration with both PrintBOS and IRIS technologies.