Package com.mailersend.sdk.emails
Class Email
- java.lang.Object
-
- com.mailersend.sdk.emails.Email
-
public class Email extends Object
Email class.
- Version:
- $Id: $Id
- Author:
- john
-
-
Field Summary
Fields Modifier and Type Field Description protected HashMap<String,Object>allRecipientsPersonalizationprotected HashMap<String,String>allRecipientsSubstitutionsArrayList<Attachment>attachmentsArrayList<Recipient>bccArrayList<Recipient>ccRecipientfromStringhtmlStringinReplyToStringlistUnsubscribeArrayList<Personalization>personalizationArrayList<Recipient>recipientsRecipientreplyToDatesendAtprotected StringsendAtStampStringsubjectArrayList<String>tagsStringtemplateIdStringtext
-
Constructor Summary
Constructors Constructor Description Email()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidAddBcc(Recipient recipient)Adds a blind carbon copy recipient to the emailvoidAddBcc(String name, String email)Adds a blind carbon copy recipient to the emailvoidAddCc(Recipient recipient)Adds a carbon copy recipient to the emailvoidAddCc(String name, String email)Adds a carbon copy recipient to the emailvoidaddPersonalization(Recipient recipient, String name, Object value)Adds a personalization for the given recipientvoidaddPersonalization(String name, Object value)Adds personalization to all recipientsvoidaddRecipient(String name, String email)Adds a recipient to the emailvoidAddRecipient(Recipient recipient)Adds a recipientvoidAddRecipients(Recipient[] recipients)Adds multiple recipients to the emailvoidAddReplyTo(Recipient replyTo)Sets the reply to parametervoidAddReplyTo(String name, String email)Sets the reply to parametervoidAddTag(String tag)Add a tag to the emailvoidAddVariable(String name, String value)Adds a variable to all recipientsvoidattachFile(File file)attachFile.voidattachFile(String path)Attach a file to the emailprotected voidpreparePersonalizationForAllRecipients()Adds each entry of the allRecipientsPersonalization hash map as a personalization for each recipientprotected voidprepareSubstitutionsForAllRecipients()Adds each entry of the allRecipientsSubstitutions hash map as a substitution for each recipientStringserializeForSending()Prepares the email for sending and returns it as a serialized JSON stringvoidsetFrom(String name, String email)Sets the email fromvoidsetHtml(String html)Sets the email's HTML bodyvoidsetInReplyTo(String inReplyTo)Set in reply tovoidsetListUnsubscribe(String listUnsubscribe)Sets the list unsubscribe parameter Accepts a single value that complies with RFC 8058 Note: This feature is available to Professional and Enterprise accounts onlyvoidsetPlain(String plain)Sets the email's plain text bofyvoidsetSendAt(Date sendAt)Set the send at datevoidsetSubject(String subject)Sets the email's subjectvoidsetTemplateId(String templateId)Sets the email's template id
-
-
-
Field Detail
-
from
@SerializedName("from") public Recipient from
-
replyTo
@SerializedName("reply_to") public Recipient replyTo
-
subject
@SerializedName("subject") public String subject
-
text
@SerializedName("text") public String text
-
html
@SerializedName("html") public String html
-
templateId
@SerializedName("template_id") public String templateId
-
attachments
public ArrayList<Attachment> attachments
-
personalization
@SerializedName("personalization") public ArrayList<Personalization> personalization
-
sendAt
public Date sendAt
-
allRecipientsPersonalization
protected transient HashMap<String,Object> allRecipientsPersonalization
-
sendAtStamp
@SerializedName("send_at") protected String sendAtStamp
-
inReplyTo
@SerializedName("in_reply_to") public String inReplyTo
-
listUnsubscribe
@SerializedName("list_unsubscribe") public String listUnsubscribe
-
-
Method Detail
-
AddRecipient
public void AddRecipient(Recipient recipient)
Adds a recipient- Parameters:
recipient- aRecipientobject.
-
AddRecipients
public void AddRecipients(Recipient[] recipients)
Adds multiple recipients to the email- Parameters:
recipients- an array ofRecipientobjects.
-
AddCc
public void AddCc(Recipient recipient)
Adds a carbon copy recipient to the email- Parameters:
recipient- aRecipientobject.
-
AddBcc
public void AddBcc(String name, String email)
Adds a blind carbon copy recipient to the email
-
AddBcc
public void AddBcc(Recipient recipient)
Adds a blind carbon copy recipient to the email- Parameters:
recipient- aRecipientobject.
-
AddReplyTo
public void AddReplyTo(Recipient replyTo)
Sets the reply to parameter- Parameters:
replyTo- aRecipientobject.
-
setSubject
public void setSubject(String subject)
Sets the email's subject- Parameters:
subject- aStringobject.
-
setHtml
public void setHtml(String html)
Sets the email's HTML body- Parameters:
html- aStringobject.
-
setPlain
public void setPlain(String plain)
Sets the email's plain text bofy- Parameters:
plain- aStringobject.
-
setTemplateId
public void setTemplateId(String templateId)
Sets the email's template id- Parameters:
templateId- aStringobject.
-
addPersonalization
public void addPersonalization(Recipient recipient, String name, Object value)
Adds a personalization for the given recipient
-
setSendAt
public void setSendAt(Date sendAt)
Set the send at date- Parameters:
sendAt- aDateobject.
-
setInReplyTo
public void setInReplyTo(String inReplyTo)
Set in reply to- Parameters:
inReplyTo- aStringobject.
-
setListUnsubscribe
public void setListUnsubscribe(String listUnsubscribe)
Sets the list unsubscribe parameter Accepts a single value that complies with RFC 8058 Note: This feature is available to Professional and Enterprise accounts only- Parameters:
listUnsubscribe- aStringobject.
-
addPersonalization
public void addPersonalization(String name, Object value)
Adds personalization to all recipients
-
attachFile
public void attachFile(String path) throws IOException
Attach a file to the email- Parameters:
path- aStringobject.- Throws:
IOException
-
attachFile
public void attachFile(File file) throws IOException
attachFile.
- Parameters:
file- aFileobject.- Throws:
IOException- if any.
-
preparePersonalizationForAllRecipients
protected void preparePersonalizationForAllRecipients()
Adds each entry of the allRecipientsPersonalization hash map as a personalization for each recipient
-
prepareSubstitutionsForAllRecipients
protected void prepareSubstitutionsForAllRecipients()
Adds each entry of the allRecipientsSubstitutions hash map as a substitution for each recipient
-
serializeForSending
public String serializeForSending()
Prepares the email for sending and returns it as a serialized JSON string- Returns:
- String
-
-