public class MimeMessageWrapper extends EmailMessage
EmailMessage that wraps related MimeMessage and provides read-only
access to its data and parameters.attachments, bccRecipients, bodyParts, bodyProperties, ccRecipients, charset, date, emailSender, forwardedMessage, from, headers, html, id, isRead, parentFolder, recipients, replyOnMessage, replyTo, sender, senderName, subject, text, typeName, USED_DATE_TME_FORMAT_PATTERN| Constructor and Description |
|---|
MimeMessageWrapper(javax.mail.internet.MimeMessage mimeMessage) |
| Modifier and Type | Method and Description |
|---|---|
EmailMessage |
attach(File file)
Attaches given file to this email message.
|
EmailMessage |
attach(Path filePath)
Attaches given file to this email message.
|
EmailMessage |
attach(String fileName,
InputStream fileContent,
String mimeType)
Attaches given file content as attachment to this email message.
|
EmailMessage |
bccRecipients(String... recipientsSequence)
Sets explicitly email addresses who are BCC recipients of this email message.
|
EmailMessage |
ccRecipients(String... recipientsSequence)
Sets explicitly email addresses who are CC recipients of this email message.
|
List<EmailAttachment> |
getAttachments()
Gets attachments attached to this email message.
|
List<EmailAddress> |
getBccRecipients()
Gets list of email addresses who are BCC recipients of this email message.
|
List<EmailBodyPart> |
getBodyParts()
Gets the list of parts that constituents the body of this email message.
|
List<EmailAddress> |
getCcRecipients()
Gets list of email addresses who are CC recipients of this email message.
|
String |
getCharset()
Gets charset of this email message body.
|
Date |
getDate()
Gets the date of this email message.
|
EmailAddress |
getFrom()
Gets email address displayed in the field
From: of this email message. |
Map<String,String> |
getHeaders()
Gets key-value map with all header parameters of this email message.
|
String |
getId()
Gets unique identifier of this email message within mailbox.
|
String |
getParentFolder()
Gets the name of mailbox folder where this email message is contained.
|
List<EmailAddress> |
getRecipients()
Gets list of email addresses who are recipients of this email message.
|
List<EmailAddress> |
getReplyTo()
Gets list of email addresses who are supposed recipients of the replying on this email message.
|
EmailAddress |
getSender()
Gets email address of the actual sender of this email message.
|
String |
getSenderName()
Gets the display name of the actual sender of this email message.
|
String |
getSubject()
Gets subject of this email message.
|
EmailMessage |
header(String key,
String value)
Sets header parameter for this email message.
|
EmailMessage |
html(String html)
Sets given HTML string as body of this email message.
|
boolean |
isRead()
Gets the value of read/unread flag of this email message.
|
boolean |
isUnread()
Gets the value of read/unread flag of this email message.
|
EmailMessage |
recipients(String... recipientsSequence)
Sets explicitly email addresses who are recipients of this email message.
|
EmailMessage |
replyTo(String... recipientsSequence)
Sets explicitly email addresses who are supposed recipients of the replying on this email message.
|
void |
send()
Sends this email message using provided email sender.
|
void |
send(EmailSender emailSender)
Sends this email message using given email sender.
|
void |
setAttachments(List<EmailAttachment> attachments)
Sets attachments for this email message.
|
void |
setBccRecipients(List<EmailAddress> recipientsList)
Sets explicitly the list of email addresses who are BCC recipients of this email message.
|
void |
setBodyParts(List<EmailBodyPart> bodyParts)
Sets the list of parts that constituents the body of this email message.
|
void |
setCcRecipients(List<EmailAddress> recipientsList)
Sets explicitly the list of email addresses who are CC recipients of this email message.
|
void |
setCharset(String charset)
Sets explicitly the charset of this email message body.
|
void |
setFrom(EmailAddress from)
Sets explicitly the email address displayed in the field
From: of this email message. |
void |
setFrom(String fromAddress)
Sets explicitly the email address displayed in the field
From: of this email message. |
void |
setHeaders(Map<String,String> headers)
Sets given key-value map as header parameters of this email message.
|
void |
setRead(boolean read)
Sets read/unread flag for this email message.
|
void |
setRecipients(List<EmailAddress> recipientsList)
Sets explicitly the list of email addresses who are recipients of this email message.
|
void |
setReplyTo(List<EmailAddress> recipientsList)
Sets explicitly the list of email addresses who are supposed recipients of the replying on this email message.
|
void |
setSender(EmailAddress sender)
Sets the email address of the actual sender of this email message.
|
void |
setSender(String senderAddress)
Sets the email address of the actual sender of this email message.
|
void |
setSenderName(String senderName)
Sets explicitly the display name of the actual sender of this email message.
|
void |
setSubject(String subject)
Sets explicitly the subject of this email message.
|
EmailMessage |
text(String text)
Sets given text string as body of this email message.
|
addHtml, addText, beforeSend, charset, excludeFromCcRecipients, excludeFromRecipients, forwardMessage, from, fromJson, getBodyProperties, getConfigParam, getDateTime, getForwardedMessage, getHtml, getReplyOnMessage, getText, hasAttachments, hasHtml, hasText, markRead, markUnread, property, replyAllMessage, replyMessage, senderName, setBodyProperties, subject, toJson, toStringpublic MimeMessageWrapper(javax.mail.internet.MimeMessage mimeMessage)
public String getId()
EmailMessageThe value of unique identifier is present only for existing email messages of the mailbox.
getId in class EmailMessagenull if this email message
is a new and have never been sent.public Date getDate()
EmailMessageThis date represents received date if the email message has been received or sent date if the email message has been just sent.
getDate in class EmailMessageDate object representing received or sent date of this email message.public String getParentFolder()
EmailMessageThe value of parent folder is present only for existing email messages of the mailbox.
getParentFolder in class EmailMessagenull if this email message
is a new and have never been sent.public Map<String,String> getHeaders()
EmailMessagegetHeaders in class EmailMessagepublic void setHeaders(Map<String,String> headers)
EmailMessageIf some of given header parameters are already present in headers of this email message then they will be overwritten. Other headers of this email message that are not present in the given map will be left without changes.
setHeaders in class EmailMessageheaders - the key-value map with header parameters to set.public EmailMessage header(String key, String value)
EmailMessageheader in class EmailMessagekey - the key string of the header parameter to set.value - the value string of the header parameter to set.public EmailAddress getSender()
EmailMessage
The sender email address automatically is set by email service and corresponds to email account on behalf of
which this message is sent. Information about this email account is provided via EmailSender.getSecret().
getSender in class EmailMessageEmailAddress object representing the email address of actual sender of this email message.public void setSender(EmailAddress sender)
EmailMessage
This method is used for serialize/deserialize of this email message into JSON and shouldn't be used
explicitly. Since the sender email address string automatically is set by email server and corresponds
to email account on behalf of which this message is sent. Information about this email account is provided
via EmailSender.getSecret().
setSender in class EmailMessagesender - the EmailAddress object with email address and its display name to set.public void setSender(String senderAddress)
EmailMessage
This method is used by email service and shouldn't be used explicitly. The sender email address
automatically is set by email service and corresponds to email account on behalf of which this message is sent.
Information about this email account is provided via EmailSender.getSecret().
setSender in class EmailMessagesenderAddress - the email address string to set.public String getSenderName()
EmailMessage
This display name is used ONLY if the value of EmailMessage.from is not specified.
If the value of EmailMessage.from is not set and the display name is not specified explicitly then it will be looked
up in configuration parameters of the RPA platform under the key that depends on the actual
EmailMessage.typeName value:
<typeName>.sender.name
In case of default typeName the key of configuration parameter is email.sender.name.getSenderName in class EmailMessagepublic void setSenderName(String senderName)
EmailMessage
The actual sender is set by email service and corresponds to email account on behalf of
which this message is sent. Using this method it is possible to specify a display name that should be
displayed in the field From: instead of email address string but ONLY if the value of EmailMessage.from
is not specified.
setSenderName in class EmailMessagesenderName - the string with display name of the sender to set.public EmailAddress getFrom()
EmailMessageFrom: of this email message.
This value can be different from the actual email sender that is returned by EmailMessage.getSender().
If this email address is not specified explicitly then it will be looked up in configuration parameters of
the RPA platform under the key that depends on the actual EmailMessage.typeName value:
<typeName>.from
In case of default typeName the key of configuration parameter is email.from.
If this email address is not set at all then email address returned by EmailMessage.getSender() will be displayed
in the field From: instead.
getFrom in class EmailMessageEmailAddress object representing email address displayed in the field From:
of this email message.public void setFrom(EmailAddress from)
EmailMessageFrom: of this email message.setFrom in class EmailMessagefrom - the EmailAddress object with email address and its display name to set.public void setFrom(String fromAddress)
EmailMessageFrom: of this email message.setFrom in class EmailMessagefromAddress - the email address string to set.public List<EmailAddress> getRecipients()
EmailMessage
This is a list of email addresses displayed in the field To: of this email message.
If recipients are not specified explicitly then they will be looked up in configuration parameters of
the RPA platform under the key that depends on the actual EmailMessage.typeName value:
<typeName>.recipients
In case of default typeName the key of configuration parameter is email.recipients.
Email addresses in the value of this configuration parameter can be delimited with ";":
email.recipients = user1@example.com;user2@example.com;user3@example.com
getRecipients in class EmailMessageEmailAddress objects representing email addresses who are recipients of this
email message.public void setRecipients(List<EmailAddress> recipientsList)
EmailMessage
These are email addresses displayed in the field To: of this email message.
setRecipients in class EmailMessagerecipientsList - the list of EmailAddress objects representing email addresses to set as recipients
of this email message.public EmailMessage recipients(String... recipientsSequence)
EmailMessage
These are email addresses displayed in the field To: of this email message.
recipients in class EmailMessagerecipientsSequence - the sequence of email address strings to set as recipients of this email message.public List<EmailAddress> getCcRecipients()
EmailMessage
This is a list of email addresses displayed in the field CC: of this email message.
If CC recipients are not specified explicitly then they will be looked up in configuration parameters of
the RPA platform under the key that depends on the actual EmailMessage.typeName value:
<typeName>.cc.recipients
In case of default typeName the key of configuration parameter is email.cc.recipients.
Email addresses in the value of this configuration parameter can be delimited with ";":
email.cc.recipients = user1@example.com;user2@example.com;user3@example.com
getCcRecipients in class EmailMessageEmailAddress objects representing email addresses who are CC recipients of this
email message.public void setCcRecipients(List<EmailAddress> recipientsList)
EmailMessage
These are email addresses displayed in the field CC: of this email message.
setCcRecipients in class EmailMessagerecipientsList - the list of EmailAddress objects representing email addresses to set as
CC recipients of this email message.public EmailMessage ccRecipients(String... recipientsSequence)
EmailMessage
These are email addresses displayed in the field CC: of this email message.
ccRecipients in class EmailMessagerecipientsSequence - the sequence of email address strings to set as CC recipients of this email message.public List<EmailAddress> getBccRecipients()
EmailMessage
This is a list of email addresses displayed in the field BCC: of this email message.
If BCC recipients are not specified explicitly then they will be looked up in configuration parameters of
the RPA platform under the key that depends on the actual EmailMessage.typeName value:
<typeName>.bcc.recipients
In case of default typeName the key of configuration parameter is email.bcc.recipients.
Email addresses in the value of this configuration parameter can be delimited with ";":
email.bcc.recipients = user1@example.com;user2@example.com;user3@example.com
getBccRecipients in class EmailMessageEmailAddress objects representing email addresses who are BCC recipients of this
email message.public void setBccRecipients(List<EmailAddress> recipientsList)
EmailMessage
These are email addresses displayed in the field BCC: of this email message.
setBccRecipients in class EmailMessagerecipientsList - the list of EmailAddress objects representing email addresses to set as
BCC recipients of this email message.public EmailMessage bccRecipients(String... recipientsSequence)
EmailMessage
These are email addresses displayed in the field BCC: of this email message.
bccRecipients in class EmailMessagerecipientsSequence - the sequence of email address strings to set as BCC recipients of this email message.public List<EmailAddress> getReplyTo()
EmailMessage
If "replay to" recipients are not specified explicitly then they will be looked up in configuration parameters
of the RPA platform under the key that depends on the actual EmailMessage.typeName value:
<typeName>.reply.to
In case of default typeName the key of configuration parameter is email.reply.to.
Email addresses in the value of this configuration parameter can be delimited with ";":
email.reply.to = user1@example.com;user2@example.com;user3@example.com
getReplyTo in class EmailMessageEmailAddress objects representing email addresses who are supposed recipients of
the replying on this email message.public void setReplyTo(List<EmailAddress> recipientsList)
EmailMessagesetReplyTo in class EmailMessagerecipientsList - the list of EmailAddress objects representing email addresses to set.public EmailMessage replyTo(String... recipientsSequence)
EmailMessagereplyTo in class EmailMessagerecipientsSequence - the sequence of email address strings to set.public String getSubject()
EmailMessage
If subject is not specified explicitly then it will be looked up in configuration parameters of the RPA platform
under the key that depends on the actual EmailMessage.typeName value:
<typeName>.subject
In case of default typeName the key of configuration parameter is email.subject.getSubject in class EmailMessagepublic void setSubject(String subject)
EmailMessagesetSubject in class EmailMessagesubject - string with subject to set.public String getCharset()
EmailMessage
If charset is not specified explicitly then it will be looked up in configuration parameters of the RPA platform
under the key that depends on the actual EmailMessage.typeName value:
<typeName>.charset
In case of default typeName the key of configuration parameter is email.charset.getCharset in class EmailMessagepublic void setCharset(String charset)
EmailMessagesetCharset in class EmailMessagecharset - string with charset to set.public List<EmailBodyPart> getBodyParts()
EmailMessage
The email message body can be in a format of simple text or HTML. For compatibility it can be presented in
both formats at the same. To achieve it the body persisted as list of body parts where each part has
specific format. To get the full body in the text or HTML format methods EmailMessage.getText() or EmailMessage.getHtml()
should be used respectively.
If there are no body parts has been added explicitly this method will try to lookup the body content in
configuration parameters of the RPA platform under the key that depends on the actual EmailMessage.typeName value:
<typeName>.body.tpl
In case of default typeName the key of configuration parameter is email.body.tpl.
Here can be actual text or HTML or it can be a path to Freemarker Template File (*.ftl) in the resources of current RPA process module. If such configuration parameter is present the content defined by this parameter will be added as HTML body part. In results the list with this single body part is returned.
getBodyParts in class EmailMessageEmailBodyPart objects representing body parts of this email message.public void setBodyParts(List<EmailBodyPart> bodyParts)
EmailMessage
This method is used for serialize/deserialize of this email message into JSON and shouldn't be used
explicitly. To set a content of the body use following methods: EmailMessage.text(String),
EmailMessage.addText(String), EmailMessage.html(String), EmailMessage.addHtml(String).
setBodyParts in class EmailMessagebodyParts - the list of EmailBodyPart objects representing body parts to set.public EmailMessage text(String text)
EmailMessageIt removes all existing text body parts and adds only one text body part with given text.
Instead of actual text string this method accepts path to FreeMarker Template File (*.ftl) in the resources of current RPA process module. In this case the content of the .ftl file will be used for adding of text body part.
text in class EmailMessagetext - the string with text to set or path to resource .ftl file with text to set.public EmailMessage html(String html)
EmailMessageIt removes all existing HTML body parts and adds only one HTML body part with given HTML.
Instead of actual HTML string this method accepts path to Freemarker Template File (*.ftl) in the resources of current RPA process module. In this case the content of the .ftl file will be used for adding of HTML body part.
html in class EmailMessagehtml - the string with HTML to set or path to resource .ftl file with HTML to set.public List<EmailAttachment> getAttachments()
EmailMessagegetAttachments in class EmailMessageEmailAttachment representing attachments attached to this email message.public void setAttachments(List<EmailAttachment> attachments)
EmailMessagesetAttachments in class EmailMessageattachments - the list of EmailAttachment representing attachments to set.public EmailMessage attach(File file)
EmailMessageattach in class EmailMessagefile - the File object representing file to attach.public EmailMessage attach(Path filePath)
EmailMessageattach in class EmailMessagefilePath - the Path to the file that need to be attached.public EmailMessage attach(String fileName, InputStream fileContent, String mimeType)
EmailMessageattach in class EmailMessagefileName - the string with file name that should be used for attached file.fileContent - the InputStream that provides the content of file to attach.mimeType - the string with content type of file to attach.public boolean isRead()
EmailMessageisRead in class EmailMessagetrue is this email message is READ or false otherwise.public boolean isUnread()
EmailMessageisUnread in class EmailMessagetrue is this email message is UNREAD or false otherwise.public void setRead(boolean read)
EmailMessage
The changing of this flag actually doesn't change anything in the mailbox. To apply these change in the mailbox
use the method EmailClient.updateMessage(EmailMessage).
setRead in class EmailMessageread - the value of read/unread flag to set. It should be true if it's necessary to mark this
email message as read and false as unread.public void send()
EmailMessage
Does nothing if this email message has not been constructed using EmailMessage(EmailSender)
or EmailMessage(String, EmailSender). In such cases is necessary to use EmailMessage.send(EmailSender)
instead.
send in class EmailMessagepublic void send(EmailSender emailSender)
EmailMessagesend in class EmailMessageemailSender - the EmailSender that should be used to send this email message.Copyright © 2023. All rights reserved.