public class Email
Email Allows for the sending of email messages, leaving the means by which the message is populated and sent up to the caller. Attachments are supported.
Modifier and Type | Field and Description |
---|---|
BBjString | mailhost$ Mail server host |
BBjNumber | mailport Mail server port, default = 25 |
jakarta.mail.internet.MimeMessage | message! MimeMessage object |
jakarta.mail.Multipart | multipart! Multipart object |
BBjString | OAuthAccessToken$ OAuth access token |
BBjString | password$ Password to use for authentication to the mail server |
BBjString | protocol$ Mail server protocol, which can be smtp or smtps |
jakarta.mail.Multipart | relatedPart! Multipart object |
BBjNumber | Retries=30 Number of retries when sending the email |
jakarta.mail.Session | session! Session object |
BBjString | username$ User name to use for authentication to the mail server |
Constructor and Description |
---|
Email() Constructor Constructs an Email without specifying any parameters, using those specified in global string variables instead. In order for this constructor to succeed, the mail server's hostname (at a minimum) must be specified via an STBL entry. This is done by setting the global string entries listed below either via code or in a configuration file.
temp$ = STBL("BASIS_UTILITY_EMAIL_SERVER", "MyMailServer")
2) Setting the global string entries in the config file, without changing any code:
SET BASIS_UTILITY_EMAIL_SERVER=smtp.comcast.net
SET BASIS_UTILITY_EMAIL_PORT=465
SET BASIS_UTILITY_EMAIL_USER=BBj@comcast.net
SET BASIS_UTILITY_EMAIL_PASSWORD=myEmailPassword
SET BASIS_UTILITY_EMAIL_SMTP=smtps
SET BASIS_UTILITY_EMAIL_FROM=BBj@comcast.net
Notes:
|
Email(BBjString mailhost$, BBjNumber mailport) Constructor Constructs a EMail given a host and a port |
Email(BBjString mailhost$, BBjNumber mailport, BBjString username$, BBjString accessToken$) Constructor Constructs a Email given a host, port, user name, and access token |
Email(BBjString mailhost$, BBjNumber mailport, BBjString username$, BBjString password$, BBjString smtp$) Constructor Constructs a Email given a host, port, user name, password, and protocol |
Modifier and Type | Method and Description |
---|---|
void | addBcc(BBjString bcc$) addBcc Sets the first recipient or an additional recipient to the blind carbon copy field in an email's header before the email is sent. This value specifies the email address to receive a copy of the message. Other recipients of the message will not be able to see that the email was sent to the specified recipient. Each invocation of this method takes one email address. Calling this method multiple times will construct a list of addresses to receive a copy of the message. Adding a recipient to the "bcc" field is not the same as adding them to the "to" field as all other recipients, including those in the "to" and "cc" fields, will not see the entries in the "bcc" field. |
void | addBcc(BBjVector bccAddresses!) addBcc Adds recipients to the "bcc" field in an email's header before the email is sent. |
void | addCc(BBjString cc$) addCc Sets the first recipient or adds an additional recipient to the "cc" field in an email's header before the email is sent. This value specifies the email addresses to receive a copy of the message. Each invocation of this method takes one email address. Calling this method multiple times will construct a list of addresses to receive a copy of the message. Adding a recipient to the "cc"" field is the same as adding it to the "to" field. Adding the recipient in the "cc" field rather than the "to" field indicates that the message is relevant to them, but is not a direct correspondence with them. |
void | addCc(BBjVector ccAddresses!) addCc Adds recipients to the "cc" field in an email's header before the email is sent. |
void | addData(BBjString data$, BBjString mime$) addData Adds data to the body of the message allowing the mime type to be specified. May be called once or multiple times to add data to the body of the email message. Data will be added cumulatively |
void | addData(FileInputStream fis!, BBjString mime$) addData Adds data to the body of the message allowing the mime type to be specified. May be called once or multiple times to add data to the body of the email message. Data will be added cumulatively |
void | addFile(BBjString filename$) addFile Adds a file attachment to the email message May be called once or multiple times to add file attachments to the email message. |
void | addFile(BBjString filename$, BBjString contentID$) addFile Adds a file attachment to the email message May be called once or multiple times to add file attachments to the email message. |
void | addFile(BBjString filename$, BBjString contentID$, BBjString mime$) addFile Adds a file attachment to the email message May be called once or multiple times to add file attachments to the email message. If the mime type is an empty string, then Apache Tika will be applied to try to detect the mime type. |
void | addImageInline(BBjString filename$, BBjString contentID$, BBjString mime$) addImageInline Adds an image to the email in such a way that it can be inlined into the HTML content. |
void | addText(BBjString text$) addText Sets the text for the body of the email message represented by the email object May be called once or multiple times to add plain text to the body of the email message. Text will be added cumulatively |
void | addTo(BBjString to$) addTo Sets the first recipient or adds an additional recipient to the "to" field in an email's header before the email is sent. This value specifies the email addresses to which the message will be delivered. Each invocation of this method takes one email address. Calling this method multiple times will construct a list of addresses that the message will be sent to. |
void | addTo(BBjVector toAddresses!) addTo Adds recipients to the "to" field in an email's header before the email is sent. |
void | send() send Sends an email message once it has been configured. At the very least, a mail server, username, password, and the "to" field (specified by the setTo() or addTo() methods) must be set before an email message can be sent. Any errors will be thrown. |
void | setBcc(BBjString bcc$) setBcc Sets the recipient for the blind carbon copy field in an email's header before the email is sent. This value specifies the email address to receive a copy of the message. Other recipients of the message will not be able to see that the email was sent to the specified recipient. This method takes one email address. To specify multiple recipients for the "bcc" field, use multiple invocations of the addBcc() method. Adding a recipient to the "bcc" field (and not including that address in the "to" and "cc" fields) hides that recipient's address from all other recipients. |
void | setCc(BBjString cc$) setCc Sets the recipient for the carbon copy field in an email's header before the email is sent. This value specifies the email address to receive a copy of the message. This method takes one email address. To specify multiple recipients for the "cc" field, use multiple invocations of the addCc() method. The cc field is visible to all email recipients. To hide addresses that emails are being sent to, consider the setBcc() and addBcc() methods. Adding a recipient to the carbon copy field is the same as adding it to the "to" field. Entering the recipient in the "cc" field rather than the "to" field indicates that the message is relevant to them, but is not a direct correspondence with them. |
void | setFrom(BBjString from$) setFrom Sets the "from" field in an email's header before the email is sent. The "from" field indicates the sending email address. Depending on the mail service provider, it may not be necessary to set this field. The value can be determined from the email account from which the mail was sent. |
void | setHeader(BBjString header$, BBjString value$) setHeader Sets various attributes of the email header The basic attributes of an email header are laid out in RFC 822, which can be found at http://www.faqs.org/rfcs/rfc822.html. |
void | setHtml(BBjString html$, BBjString basedir$) setHtml Sets the html for the email |
void | setOAuthAccessToken(BBjString accesToken$) setOAuthAccessToken Set the OAuth access token for authentication when sending an email |
void | setReplyTo(BBjString replyTo$) setReplyTo Sets the "reply to" field in an email's header before the email is sent. The "reply to" field indicates to what email address a reply should be sent. This method is optional. Replies will be directed to the from address if this value is not set |
void | setSentDate(Date date!) setSentDate Sets the "sent date" field in an email's header before the email is sent. It is not necessary to call this method unless some date other than the current date needs to be specified as the sent date. Changing this date will not change the actual time at which the email is sent. i.e., setting the sent date forward a day in the future will not cause the sending of the email to be delayed a day. |
void | setSubject(BBjString subject$) setSubject Sets the subject of the email message represented by the email object |
void | setText(BBjString text$) setText Sets the text for the body of the email message Alias of addText(). Can be called multiple times to add multiple text parts to the email message. |
void | setTo(BBjString to$) setTo Sets the "to" field in an email's header before the email is sent. This value specifies the email address to which the message will be delivered. This method only supports one email address. Add additional recipients using the addTo() method. |
BBjString | toJSON() toJSON Converts the email to a JSON string. |
public BBjString mailhost$
Mail server host
public BBjNumber mailport
Mail server port, default = 25
public jakarta.mail.internet.MimeMessage message!
MimeMessage object
public jakarta.mail.Multipart multipart!
Multipart object
public BBjString OAuthAccessToken$
OAuth access token
25.01
public BBjString password$
Password to use for authentication to the mail server
public BBjString protocol$
Mail server protocol, which can be smtp or smtps
public jakarta.mail.Multipart relatedPart!
Multipart object
public BBjNumber Retries=30
Number of retries when sending the email
public jakarta.mail.Session session!
Session object
public BBjString username$
User name to use for authentication to the mail server
public Email()
Constructor Constructs an Email without specifying any parameters, using those specified in global string variables instead. In order for this constructor to succeed, the mail server's hostname (at a minimum) must be specified via an STBL entry. This is done by setting the global string entries listed below either via code or in a configuration file.
temp$ = STBL("BASIS_UTILITY_EMAIL_SERVER", "MyMailServer")
2) Setting the global string entries in the config file, without changing any code:
SET BASIS_UTILITY_EMAIL_SERVER=smtp.comcast.net
SET BASIS_UTILITY_EMAIL_PORT=465
SET BASIS_UTILITY_EMAIL_USER=BBj@comcast.net
SET BASIS_UTILITY_EMAIL_PASSWORD=myEmailPassword
SET BASIS_UTILITY_EMAIL_SMTP=smtps
SET BASIS_UTILITY_EMAIL_FROM=BBj@comcast.net
Notes:
BASIS_UTILITY_EMAIL_FROM
parameter is only used with the EmailDialog class. You
must call the setFrom() method when using the Email class.BASIS_UTILITY_EMAIL_SMTP
parameter are either 'smtp' or 'smtps'. The
value will be used as-is for the Email class, and will be translated into either a 0 or 1 for the EmailDialog's
EmailServerSSL setting. 16.0
public Email(BBjString mailhost$, BBjNumber mailport)
Constructor Constructs a EMail given a host and a port
mailhost$
Mail server hostmailport$
Mail server portpublic Email(BBjString mailhost$, BBjNumber mailport, BBjString username$, BBjString accessToken$)
Constructor Constructs a Email given a host, port, user name, and access token
mailhost$
Mail server hostmailport$
Mail server portusername$
User name used to authenticate to mail serveraccessToken$
Token used to authenticate to mail server 25.01
public Email(BBjString mailhost$, BBjNumber mailport, BBjString username$, BBjString password$, BBjString smtp$)
Constructor Constructs a Email given a host, port, user name, password, and protocol
mailhost$
Mail server hostmailport$
Mail server portusername$
User name used to authenticate to mail serverpassword$
Password used to authenticate to mail serversmtp$
Protocol to use to mail server, which can be smtp or smtpspublic void addBcc(BBjString bcc$)
addBcc Sets the first recipient or an additional recipient to the blind carbon copy field in an email's header before the email is sent. This value specifies the email address to receive a copy of the message. Other recipients of the message will not be able to see that the email was sent to the specified recipient.
Each invocation of this method takes one email address. Calling this method multiple times will construct a list of addresses to receive a copy of the message.
Adding a recipient to the "bcc" field is not the same as adding them to the "to" field as all other recipients, including those in the "to" and "cc" fields, will not see the entries in the "bcc" field.
bcc$
Bcc email address to addpublic void addBcc(BBjVector bccAddresses!)
addBcc Adds recipients to the "bcc" field in an email's header before the email is sent.
bccAddresses!
BBjVector of email addresses to addpublic void addCc(BBjString cc$)
addCc Sets the first recipient or adds an additional recipient to the "cc" field in an email's header before the email is sent. This value specifies the email addresses to receive a copy of the message.
Each invocation of this method takes one email address. Calling this method multiple times will construct a list of addresses to receive a copy of the message.
Adding a recipient to the "cc"" field is the same as adding it to the "to" field. Adding the recipient in the "cc" field rather than the "to" field indicates that the message is relevant to them, but is not a direct correspondence with them.
cc$
Cc email address to addpublic void addCc(BBjVector ccAddresses!)
addCc Adds recipients to the "cc" field in an email's header before the email is sent.
ccAddresses!
BBjVector of email addresses to addpublic void addData(BBjString data$, BBjString mime$)
addData Adds data to the body of the message allowing the mime type to be specified.
May be called once or multiple times to add data to the body of the email message. Data will be added cumulatively
data$
Data to addmime$
Mime type of datapublic void addData(FileInputStream fis!, BBjString mime$)
addData Adds data to the body of the message allowing the mime type to be specified.
May be called once or multiple times to add data to the body of the email message. Data will be added cumulatively
fis!
FileInputStream object which contains the data to add to the emailmime$
Mime type of datapublic void addFile(BBjString filename$)
addFile Adds a file attachment to the email message
May be called once or multiple times to add file attachments to the email message.
filename$
Path to file to add to the emailpublic void addFile(BBjString filename$, BBjString contentID$)
addFile Adds a file attachment to the email message
May be called once or multiple times to add file attachments to the email message.
filename$
Path to file to add to the emailcontentID$
Specifies the Content-ID header for the filepublic void addFile(BBjString filename$, BBjString contentID$, BBjString mime$)
addFile Adds a file attachment to the email message
May be called once or multiple times to add file attachments to the email message.
If the mime type is an empty string, then Apache Tika will be applied to try to detect the mime type.
filename$
Path to file to add to the emailcontentID$
Specifies the Content-ID header for the filemime$
Specifies the Content-Type header for the filepublic void addImageInline(BBjString filename$, BBjString contentID$, BBjString mime$)
addImageInline Adds an image to the email in such a way that it can be inlined into the HTML content.
filename$
Path to image file to add to the emailcontentID$
Specifies the Content-ID header for the filemime$
Specifies the mime type of the imagepublic void addText(BBjString text$)
addText Sets the text for the body of the email message represented by the email object
May be called once or multiple times to add plain text to the body of the email message. Text will be added cumulatively
text$
Text to addpublic void addTo(BBjString to$)
addTo Sets the first recipient or adds an additional recipient to the "to" field in an email's header before the email is sent. This value specifies the email addresses to which the message will be delivered.
Each invocation of this method takes one email address. Calling this method multiple times will construct a list of addresses that the message will be sent to.
to$
To email address to addpublic void addTo(BBjVector toAddresses!)
addTo Adds recipients to the "to" field in an email's header before the email is sent.
toAddresses!
BBjVector of email addresses to addpublic void send()
send Sends an email message once it has been configured.
At the very least, a mail server, username, password, and the "to" field (specified by the setTo() or addTo() methods) must be set before an email message can be sent. Any errors will be thrown.
public void setBcc(BBjString bcc$)
setBcc Sets the recipient for the blind carbon copy field in an email's header before the email is sent. This value specifies the email address to receive a copy of the message. Other recipients of the message will not be able to see that the email was sent to the specified recipient.
This method takes one email address. To specify multiple recipients for the "bcc" field, use multiple invocations of the addBcc() method. Adding a recipient to the "bcc" field (and not including that address in the "to" and "cc" fields) hides that recipient's address from all other recipients.
bcc$
Bcc email addresspublic void setCc(BBjString cc$)
setCc Sets the recipient for the carbon copy field in an email's header before the email is sent. This value specifies the email address to receive a copy of the message.
This method takes one email address. To specify multiple recipients for the "cc" field, use multiple invocations of the addCc() method. The cc field is visible to all email recipients. To hide addresses that emails are being sent to, consider the setBcc() and addBcc() methods.
Adding a recipient to the carbon copy field is the same as adding it to the "to" field. Entering the recipient in the "cc" field rather than the "to" field indicates that the message is relevant to them, but is not a direct correspondence with them.
cc$
Cc email addresspublic void setFrom(BBjString from$)
setFrom Sets the "from" field in an email's header before the email is sent. The "from" field indicates the sending email address.
Depending on the mail service provider, it may not be necessary to set this field. The value can be determined from the email account from which the mail was sent.
from$
From email addresspublic void setHeader(BBjString header$, BBjString value$)
setHeader Sets various attributes of the email header
The basic attributes of an email header are laid out in RFC 822, which can be found at http://www.faqs.org/rfcs/rfc822.html.
header$
Header keyvalue$
Header valuepublic void setHtml(BBjString html$, BBjString basedir$)
setHtml Sets the html for the email
html$
HTML formatted string to add to the emailbasedir$
Specifies the base directory to find HTML referenced files such as imagespublic void setOAuthAccessToken(BBjString accesToken$)
setOAuthAccessToken Set the OAuth access token for authentication when sending an email
accesToken$
Access token 25.01
public void setReplyTo(BBjString replyTo$)
setReplyTo Sets the "reply to" field in an email's header before the email is sent. The "reply to" field indicates to what email address a reply should be sent.
This method is optional. Replies will be directed to the from address if this value is not set
replyTo$
Reply to email addresspublic void setSentDate(Date date!)
setSentDate Sets the "sent date" field in an email's header before the email is sent.
It is not necessary to call this method unless some date other than the current date needs to be specified as the sent date. Changing this date will not change the actual time at which the email is sent. i.e., setting the sent date forward a day in the future will not cause the sending of the email to be delayed a day.
date!
Sent datepublic void setSubject(BBjString subject$)
setSubject Sets the subject of the email message represented by the email object
subject$
Subject of emailpublic void setText(BBjString text$)
setText Sets the text for the body of the email message
Alias of addText(). Can be called multiple times to add multiple text parts to the email message.
text$
Text to setpublic void setTo(BBjString to$)
setTo Sets the "to" field in an email's header before the email is sent. This value specifies the email address to which the message will be delivered.
This method only supports one email address. Add additional recipients using the addTo() method.
to$
To email addresspublic BBjString toJSON()
toJSON Converts the email to a JSON string.