You are not logged in.
Pages: 1
I have 2 fields that i collected previously called "realname" and "value". I want to send these fields in an email.
The SMTP Connector looks as follows:
<Connector id="SMTPEmail" type="SMTP">
<Connection xsi:type="sxi:SMTP">
<sxi:Server>smtp.gmail.com</sxi:Server>
<sxi:User>ofi@sxi.co.za</sxi:User>
<sxi:Password>XXXXXX</sxi:Password>
<sxi:RetryDelay>60</sxi:RetryDelay>
<sxi:AuthType>SSL</sxi:AuthType>
<sxi:Port>465</sxi:Port>
<sxi:FromAddress>ofi@sxi.co.za</sxi:FromAddress>
</Connection>
<sxi:ReturnCodes>
<sxi:Success />
<sxi:RecoverableError />
</sxi:ReturnCodes>
</Connector>
"Server" is the name of the SMTP mail server where the connection will be made.
"User" must contain the username used to authenticate with the SMTP server.
"Password" for the above mentioned user. NOTE: The password must not contain an @ sign.
"AuthType" is set to SSL. The "Port" must be 465, otherwise if AuthType is set to TLS the "Port" must be 587. It's easier to use SSL as TLS needs additional configuration.
"FromAddress" is the email address where the email will be sent from.
I have a "Create" mapping that looks as follows:
<Create dataDefinition="DetailsToSendEmail" connectorId="SMTPEmail" source="na"/>
The DataDefinition to use with SMTP must have the following output fields:
To
Subject
Body
The full DataDefinition will look as follows:
<sxi:DataDefinition name="DetailsToSendEmail">
<sxi:Fields>
<sxi:Field name="na">
<sxi:Rules>
<sxi:Default>recipient.name@acme.com</sxi:Default>
</sxi:Rules>
<sxi:OutputField datatype="recipients">To</sxi:OutputField>
</sxi:Field>
<sxi:Field name="Subject">
<sxi:Rules>
<sxi:Concatenation>
<sxi:Delimiter> </sxi:Delimiter>
<sxi:Fields>
<sxi:Field staticValue="yes">Person:</sxi:Field>
<sxi:Field>realname</sxi:Field>
<sxi:Field staticValue="yes">Was Queried.</sxi:Field>
</sxi:Fields>
</sxi:Concatenation>
</sxi:Rules>
<sxi:OutputField>Subject</sxi:OutputField>
</sxi:Field>
<sxi:Field name="Body">
<sxi:Rules>
<sxi:Concatenation>
<sxi:Delimiter> </sxi:Delimiter>
<sxi:Fields>
<sxi:Field staticValue="yes">Person's real name =</sxi:Field>
<sxi:Field>realname</sxi:Field>
<sxi:Field staticValue="yes">
Value returned =</sxi:Field>
<sxi:Field>value</sxi:Field>
</sxi:Fields>
</sxi:Concatenation>
</sxi:Rules>
<sxi:OutputField>Body</sxi:OutputField>
</sxi:Field>
</sxi:Fields>
</sxi:DataDefinition>
Because i don't have a recipient in memory and I always want to send to "recipient.name@acme.com" I just add a default to the required output field called To and the datatype must be recipients as seen below:
<sxi:Field name="na">
<sxi:Rules>
<sxi:Default>recipient.name@acme.com</sxi:Default>
</sxi:Rules>
<sxi:OutputField datatype="recipients">To</sxi:OutputField>
</sxi:Field>
As you can see I used the Concatenation Rule to populate both my subject and body.
<sxi:Field name="Subject">
<sxi:Rules>
<sxi:Concatenation>
<sxi:Delimiter> </sxi:Delimiter>
<sxi:Fields>
<sxi:Field staticValue="yes">Person</sxi:Field>
<sxi:Field>realname</sxi:Field>
<sxi:Field staticValue="yes">Was Queried.</sxi:Field>
</sxi:Fields>
</sxi:Concatenation>
</sxi:Rules>
<sxi:OutputField>Subject</sxi:OutputField>
</sxi:Field>
<sxi:Field name="Body">
<sxi:Rules>
<sxi:Concatenation>
<sxi:Delimiter> </sxi:Delimiter>
<sxi:Fields>
<sxi:Field staticValue="yes">Person's real name =</sxi:Field>
<sxi:Field>realname</sxi:Field>
<sxi:Field staticValue="yes">
Value returned =</sxi:Field>
<sxi:Field>value</sxi:Field>
</sxi:Fields>
</sxi:Concatenation>
</sxi:Rules>
<sxi:OutputField>Body</sxi:OutputField>
</sxi:Field>
This will result in an email that looks like this:
From: ofi@sxi.co.za
To: recipient.name@acme.com
Subject: Person Fred Flintstone was queried.
Body:
Person's real name = Fred Flintstone
Value returned = 1500
Offline
One way to add attachments is to have the file you want to attach stored on the local storage drive, then just add the following to the "DataDefinition":
<sxi:Field name="NA">
<sxi:Rules>
<sxi:Concatenation>
<sxi:Delimiter/>
<sxi:Fields>
<sxi:Field staticValue="yes">X:\ATTACHMENT\FILE\PATH\</sxi:Field>
<sxi:Field>//*[local-name()='AttachmentFileName']</sxi:Field>
</sxi:Fields>
</sxi:Concatenation>
</sxi:Rules>
<sxi:OutputField datatype="file_attachment">Attachment</sxi:OutputField>
</sxi:Field>
The field containing "AttachmentFileName" is useing an object in memory with the files name.
Last edited by MarekR (27-01-2020 14:22:16)
Offline
If the from address needs to change per transaction you can also change it in the "DataDefinition", this will overwrite whatever is configured in the SMTP Connector.
Add the following field to the "DataDefinition":
<sxi:Field name="NA">
<sxi:Rules>
<sxi:Default>Sender.name@Flintstones.com</sxi:Default>
</sxi:Rules>
<sxi:OutputField>From</sxi:OutputField>
</sxi:Field>
You could also remove the default rule and use an object in memory.
Last edited by MarekR (27-01-2020 14:42:28)
Offline
Pages: 1