Instantiation
After loading credentials withConfigurationManager.getProperties(...), create the service:
Building a message
Messages are built by setting properties onMessage, Header, and Content objects, then wiring them together:
Attachments
Base64-encode the file content before setting it on the attachment:Send a message
SendMessageResponse fields:
Check delivery status
deliveryStatus values: delivered, opened, failed, pending.
Error handling
BothsendMessage and getEmailDisposition declare throws Exception. Wrap calls in a try/catch block: