Was this helpful?
SMTP Email Invoker
SMTP Email Invoker supports sending text and binary emails.
Email components support encoding in all character sets when email is sent and received. The message header and body are encoded in the character set specified by the MIME type. The email components support only Base64 and other MIME encoding. Enriched encoding is not supported.
Note:  The SMTP Email Invoker component implicitly trust the certificates presented by the email servers that require SSL or TLS connections, regardless of the issuer.
SMTP Email Invoker Properties
Property Name
Description
User Name
The username to connect to the SMTP mail server.
A valid username is required if SMTP Authentication is set to TRUE and can be left blank if SMTP Authentication is set to FALSE (for anonymous login).
Password
The password to authenticate the above username.
A valid password is required if SMTP Authentication is set to TRUE and can be left blank if SMTP Authentication is set to FALSE (for anonymous login).
Server Name
Type a valid server name.
Port
The port number. Default is 25.
Note:  If the default port is not used, then the component assumes a secure (SSL or TLS) connection.The port number for SSL is 465 and TLS is 587.
ConnectionTimeOut
Connection time-out in seconds. The default is 90.
Retry Count
Number of attempts the server tries to establish connection when connection times out or fails. Default is three attempts.
From
Email address of sender.
Reply-To
Email address for replies.
To
Email address of the recipient. You can specify multiple recipients delimited with commas and no space between the comma and the next recipient. Also, you can right-click and select Paste Macro to specify multiple recipients in one macro.
To List
Full path to a text file that contains email addresses (comma-separated).
Subject
Subject of the message.
Attachment
Document(s) attached with the email message. You can specify multiple attachments delimited with commas and no space between the comma and the next attachment. Also, you can right-click and select Paste Macro to specify multiple attachments in one macro.
SMTP authentication
Specifies if mail server authentication is required.
TRUE (default) - When set to TRUE, the server requires a username and password for authentication.
FALSE - When set to FALSE, the username and password is left blank for anonymous login.
Encoding String
Encoding string required for the email. Default is ISO-8859-1.
Content Type
The content type for the email body:
text/plain
text/html
text/richtext
Email Attachment
Both Email send and get components support attachments. For email sender (SMTP Invoker), attachment can be added to the djmessage or sent as file attachment in the Attachment option. For POP3 Queue or IMAP Queue, attachment is from djmessage. For information about the target djmessage attachment, see POP3 Email Queue and JMS Queue.
Djmessage attachment has the following three properties:
Content-Type: MIME type identifies the type of attachment content that is being sent, which is the same as email content-type. The following table provides the supported content types for email attachments using djmessage.
Content Type
Details
text/*
Text
HTML
image/*
.gif
.jpg
application/*
All applicable file extensions such as .doc, .xls, and .zip.
Content-Transfer-Encoding: Defines encoding methods for transforming binary email message data into the US-ASCII plain text format. Content transfer encoding is defined in RFC 2045. Base64 encoding is the scheme used to transmit binary data.
FileName: String containing the filename of the attachment.
Supported Actions
Action
Description
Connect
Establishes a connection to a SMTP server, which is useful when you are testing your configuration.
Execute
Executes the supported parameters and properties.
Disconnect
Breaks the connection with an SMTP server which is useful when you need to disconnect before a process is complete.
Supported Action Parameters
Action
Parameter
Description
Execute
SourceMessage
Input message
Errors
Errors are generated when email messages cannot be sent or received. Typical errors include the following:
Connection time-out
Unable to disconnect from the email server
Errors while sending email messages
Errors while receiving email messages
Miscellaneous or unknown errors
All errors are written to an error log, which you can use to diagnose and troubleshoot the problem. Error messages specify whether a problem occurred while receiving or sending.
The error log also contains error codes that help you identify and understand the cause of the error. The following table describes error codes generated while sending or receiving email.
 
Code
Description
19
Unable to connect to the mail server
27
Unable to disconnect from the mail server
8
Unable to send email
4
Unable to receive email
50
Unknown error
1
End of File
12
No more messages to download
0
Messages sent or received successfully
Example
The following process demonstrates how to send an email using the SMTP Email Invoker type of process step and receive email using the POP 3 Email Queue type of process step. In both SMTP Email Invoker and POP 3 Email Queue components, the Subject component property is a basic property for sending and retrieving emails. In this sample, a date variable is added to the value of "Subject" dynamically, so that the retrieved (get) emails are filtered by the sending the date contained in the Subject property.
Actian DataConnect uses a djMessage object (srcmsg) to define properties of the SMTP type email, such as email body and attachment, and uses another djMessage object (trgmsg) to get properties of the retrieved email, such as email body and attachment, with accessing method of POP3 from the same email server. The maximum size limit for DJMessage is 2 GB.
See the following Set Attachment script for setting the email body and email attachment and the Get Attachment script for retrieving the email body and attachment.
The expression for Set Attachment script step:
set srcmsg = new djmessage "srcmsg"
set trgmsg =new djmessage("trgmsg")
srcmsg.body="EMail_GetAttachment_" & Date()
set attachmsg1 = new DJMessage "attachmsg1"
attachmsg1.body=fileread( MacroExpand("$(Fundamentals_Data_In)") & "/TUTOR1.ASC",ENC_ISO8859_1)
srcmsg.addAttachment(attachmsg1)
set attachmsg2 = new DJMessage "attachmsg2"
attachmsg2.properties("Content-Transfer-Encoding") = "base64"
attachmsg2.properties("Content-Type") = "application/vnd.ms-excel"
attachmsg2.body=B64Encode(fileread( MacroExpand("$(Fundamentals_Data_In)") & "/ExcelV4_TUTOR1.xls",ENC_ISO8859_1),ENC_ISO8859_1)
srcmsg.addAttachment(attachmsg2)
attachmsg2.properties("FileName") = "ExcelV4_TUTOR1.xls
The expression used for Get Attachment script step:
LogMessage("INFO","Source Count: " & srcmsg.attachmentCount())
LogMessage("INFO","Target Count: " & trgmsg.attachmentCount())
For i=0 to trgmsg.attachmentCount()-1
set msgAttach1 = trgmsg.getAttachment(i)
if strcomp(msgAttach1.properties("Content-Transfer-Encoding"),"base64",1)==0 then
decmsg=B64Decode(msgAttach1.body,ENC_ISO8859_1)
FileWrite("$(Fundamentals_Data_Out)/Email_Attachment1.XLS", decmsg,ENC_ISO8859_1)
else
decmsg=StrReplace(chr(13) & chr(10), chr(10),msgAttach1.body)
FileWrite("$(Fundamentals_Data_Out)/Email_Attachment2.TXT", decmsg,ENC_ISO8859_1)
end if
Next
 
FileWrite(MacroExpand("$(Fundamentals_Data_Out)") & "/Email_body.txt", trgmsg.body)
Last modified date: 12/03/2024