Contents Hide
ScriptSession.logInfo("Sending email...") ;
var email = new Email("mail.domainname.com.au", 25, "dev@domainname.com.au", "test1@domainname.com.au") ;
email.setSubject("Testing") ;
email.setBody("Please ignore !\nThis is test message\n\nRegards\nBright Software") ;
//email.setText("Testing", "Testing ignore!") ;
email.addCC("test2@domainname.com.au") ;
email.addAttachment("\\temp\\Instructions.txt") ;
email.send() ;
ScriptSession.logInfo("Email sent successfully.") ;
Note:
email is a Email object, initialised by the Email() constructor method
Change the dummy mail server address and email addresses before using the code snippet
Also change the attachment file name to send an attachment with the message
setText method call has been commented out and can be used instead of setSubject and setBody methods
send() sends the prepared message
ScriptSession.logInfo("Sending email...") ;
var email = new Email("smtp.gmail.com", 587, "example.src@gmail.com", "example.dest@gmail.com") ;
email.setSubject("Test Email via TLS") ;
email.setBody("Test Body") ;
email.setUserCredentials("example.src@gmail.com", "password");
email.setProperty("mail.smtp.starttls.enable", "true") ;
email.send() ;
ScriptSession.logInfo("Email sent successfully.") ;
Note:
email is a Email object, initialised by the Email() constructor method
The email will be sent to "example.dest@gmail.com".
Example uses Gmail's SMTP server, with "example.src@gmail.com" as the login, and "password" as the password for the account. If the email does not send, please refer to the server log - Google account settings, such as generating an application specific password, or allowing additional access may need to be performed to connect successfully.
As setEnableSSL and SetProtocol are not called, default OFF and SMTP values will be used.
send() sends the prepared message
ScriptSession.logInfo("Sending email...") ;
var email = new Email("imap.gmail.com", 993, "example.src@gmail.com", "example.dest@gmail.com") ;
email.setSubject("Test Email via SSL") ;
email.setBody("Test Body") ;
email.setUserCredentials("example.src@gmail.com", "password");
email.setEnableSSL(true);
email.setProtocol("imap");
email.send() ;
ScriptSession.logInfo("Email sent successfully.") ;
Note:
email is a Email object, initialised by the Email() constructor method
The email will be sent to "example.dest@gmail.com".
Example uses Gmail's IMAP server, with "example.src@gmail.com" as the login, and "password" as the password for the account. If the email does not send, please refer to the server log - Google account settings, such as generating an application specific password, or allowing additional access may need to be performed to connect successfully.
send() sends the prepared message