i
Email Sending
Email delivery is administrated by a single model class and a single service class, included in the Deyel SDK.
The model class contains the properties with its getters and setters, while the service class contains the operations to be performed with the model.
Email Model Class Content
The "Email" model contains:
•Model constructor.
•Getters and setters to access the email properties.
Getters and setters of the Email model properties
Operation |
Description |
Parameters |
---|---|---|
getTo() |
Retrieves the list of recipients' email addresses. |
|
getCc() |
Retrieves the list of email addresses of those who will receive a carbon copy of the email. |
|
getBcc() |
Retrieves the list of email addresses of those who will receive a blind carbon copy of the email. |
|
getReplyTo() |
Retrieves the list of email addresses configured with automatic response. |
|
getSubject() |
Allows to retrieve the email subject. |
|
setSubject() |
Allows to define the email subject. |
String subject: Email subject |
getText() |
Allows to retrieve the email text. |
|
setText() |
Allows to define the email text. |
String text: Email text |
getAttachments() |
Allows to retrieve the list of email attachments. |
|
setAttachments() |
Allows to define a list of attachments to the email. |
List of Files: Files that are sent as attachments in the email |
getAttachmentReferences() |
Allows to retrieve the set of file references associated with the email. |
|
setAttachments() |
Allows to define the set of references to files and associate them to the email. |
FileReference List |
The Reply To attribute in the email standard allows to assign recipient addresses of the reply email. When the email recipient selects “Reply” from their email client, the boxes entered with Reply To are proposed as recipients and can be updated if the user so wishes.
The maximum defined for the total sum of the attached files size is 25mb, both for File and FileReference objects.
EmailService Service Class Content
Service allows the following operation to be performed:
Operation |
Description |
Parameters |
---|---|---|
send(email) |
Sends an email. |
Email email: Email model class |
Example of Use
The example contains the use of "EmailService" service class.
1- Sending an email with an attachment
In this example, an email is sent where its different sections are specified: ”Recipient”, “With carbon copy”, “With a blind copy”,
“Reply to”, “Subject”, “Email body”. An invitation card generated by an external method is attached to the email (generating the file is not covered in this example).
The “EmailService” service and the “Email” model class are instantiated, and the value of their properties is indicated by means of the corresponding getters and setters of the model class.
An invitation card is created, which is attached to the "Email" model class with the corresponding method.
To send the email, the send(email) method of the “EmailService” service is executed.
EmailService emailService = new EmailService(getApiClient());
Email email = new Email();
email.getTo().add("partner@gmail.com");
email.getCc().add("afarias@deyel.com");
email.getBcc().add("slopez@deyel.com");
email.getReplyTo().add("contact@deyel.com");
email.setSubject("Invitation to Event");
email.setText("Hi Partner!!, our new webinar will be next Friday..");
File invitationCardFile = createInvitationCard();
email.getAttachments().add(invitationCardFile);
emailService.send(email); emailService.send(email); |
2- Sending an email with an attached file read from a form field
This example shows two alternatives for retrieving a file from a form. The retrieved file is sent by email.
The Java object model of a form provides methods to retrieve the reference to the file stored in its fields. This reference is a more efficient Java object for this type of operation and allows for faster rule processing time.
When the files retrieved from a form are sent via email, the use of the FileReference alternative is recommended.
An “Account” form instance is read using the read(account) method of the “AccountService” service class.
AccountService accountService = new AccountService(getApiClient()); Account account = new Account(); account.setIdAccount(50); account = accountService.read(account);
|
File Alternative
The "fllogo" field of the "Account" form is retrieved, creating a new File object and the file is sent by email.
File logo = accountService.getFlLogo(account); email.getAttachments().add(logo); emailService.send(email);
|
The "fllogo" field of the "Account" form is retrieved, using FileReference and the file is sent by email.
FileReference logoReference = account.getReference_FlLogo(); email.getAttachmentReferences().add(logoReference); emailService.send(email);
|