Technical Articles
SAP Cloud Integration(CPI): Customizing Email using Mail Adapter
Dear Reader,
This is my first blog post and through this article I would like to share my experience on designing custom email templates using the mail adapter in SAP Cloud Integration.
Cloud Integration has multiple Connectivity Adapters (technical protocols used to connect a sender or receiver to the tenant) such as Amazon Webservices, Ariba, Facebook, HTTPs, JDBC, Mail, SOAP, Twitter and various other adapters, which can be used depending on the scenario.
In this blog post, I shall explain how I designed my own Custom Template for sending emails using the Mail Adapter.
IFlow
In the IFlow, I have used:
1) Start Timer: to trigger the message the moment the IFlow is deployed.
2) Content Modifier: to call the elements in the body of the email.
Header as, ${header.elementName}
Property as, ${property.elementName} and
Message Body as ${in.body} in the subject/body of the email.
In the Operate and Monitor Integrations Scenario tab–>go to Security Material, and add User Credentials:
Security Material
Enter the User ID, and password of your Outlook account, and Deploy(Please ensure that your ID is unblocked for API mail sending)
User Credentials
For Mail Adapter connection details that need to be maintained refer to the screenshot below:
Connection Details
1) Address: maintain the address as smtp.office365.com:587 where, smtp.office365.com is the address which allows the sender to check the domain of the sender through the email ID provided, and 587 here is the port behind the SSL certificate for security.
Similarly smtp.gmail.com can be used only for Google Customers i.e. Gmail users. If you wish to use other Mail ID’s, you can make the necessary changes and ensure that you use the standard port. These are the different standard ports used by Google, Microsoft, Yahoo, Rediff and GoDaddy respectively 587, 465, 995, 993 and 25.
2) Credential Name: use the same name that is maintained in the Security Material.
3) Mail Attributes: mention the ID which has been unblocked for API mail sending and in the recipient section multiple addresses can be added which are separated by (; or ,)
In the Subject, and Mail Body enter your Email context. You can also call the Header, Property, and Message Body of the Content Modifier using ${in.body}
Mail Attributes
HTML Sample Code For the Customized Email Template:
<img align="right" src="https://th.bing.com/th/id/OIP.5BfaVQJUih4hd8etGT0RdQHaDx?w=314&h=178&c=7&r=0&o=5&dpr=1.5&pid=1.7" "width="60" height="60" alt="img"/>
</br>
</br>
<style="color:#000000;font-size:15px">Hello Team,</i></br><p/>
<style="color:#000000;font-size:15px">This email is to..</br>
<i style="color:#000FFF;font-size:15px">(Content)</br><p/>
<i style="color:#000000;font-size:16px">Thanks & Regards,</i></br>
<i style="color:#000000;font-size:16px">Signature.</i></br>
<a href="https://people.sap.com/sanjana.satyan">Website</a>
</br>
</br>
</br>
<table style="width:73%">
<tr><td style="background-color:#00BFFF;color:white"><b>CPI Tenant:</b></td><td>${property.CPI_Environment}</td></tr>
<tr><td style="background-color:#1E90FF;color:white"><b>Date:</b></td><td>${date:now:yyyy-MM-dd}</td></tr>
<tr><td style="background-color:#00BFFF;color:white"><b>Time:</b></td><td>${date:now:hh:mm:ss}</td></tr>
<tr><td style="background-color:#1E90FF;color:white"><b>Message ID:</b></td><td>${header.SAP_MessageProcessingLogID}</td></tr>
<tr><td style="background-color:#00BFFF;color:white"><b>Integration Flow Name:</b></td><td>${camelId}</td></tr>
<tr><td style="background-color:#1E90FF;color:white"><b>Exception Message:</b></td><td>${exception.message}</td></tr>
</table>
</br></br>
After you deploy the IFlow, a message shall be triggered, and you shall get an Email like the template attached below:
Hope this was informative 😊
You can also check out these links related to configuring the Mail Sender and Receiver Adapter:
https://help.sap.com/viewer/368c481cd6954bdfa5d0435479fd4eaf/Cloud/en-US/e23e9cce8a974b8c8012ffcad5494766.html
https://help.sap.com/viewer/368c481cd6954bdfa5d0435479fd4eaf/Cloud/en-US/f68d5e03fd574f509f89474f6a6e272a.html
If you have any further queries on the customization mentioned or mail adapter configuration, please feel free to drop a comment below.
You can also post your questions on https://answers.sap.com/tags/67837800100800006801
Best Wishes,
Sanjana Satyan
Welcome to the world of blogging. 🎉
Keep them coming. ❤
Thank you Sookriti Mishra ❤
HI
Thanks for the above IFLOW. In this case do we need get outlook certificates?. As i dont see any certificates for Outlook that are displaying.
Hi Surendra,
I have not used any Outlook Certificates while designing the IFlow.
Thank you for sharing the blog. FYI - minutes and months are backward in sample code 🙂
Thanks, yes hadn't noticed that.
Hi Sanaja,
Good blog.
you could have showed how you maintained the entries in CM......its just a suggestion.
Regards,
Mastan
Thanks 🙂
Can we use use subject rtl?
Yes
Thanks for the informative blog Sanjana.
I am getting the following error:
LastError = com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.ofice365.com, 587; timeout 30000;
nested exception is:
java.net.UnknownHostException: smtp.ofice365.com, cause: java.net.UnknownHostException: smtp.ofice365.com
LastErrorModelStepId= MessageFlow_8
Please assist.
Jay
Hi Jay,
Did you check whether the SMTP server and port are correct?