Modifier and Type | Field and Description |
---|---|
BBjString |
mailhost$
Mail server host
|
BBjNumber |
mailport
Mail server port, default = 25
|
MimeMessage |
message!
MimeMessage object
|
Multipart |
multipart!
Multipart object
|
BBjString |
password$
Password to use for authentication to the mail server
|
BBjString |
protocol$
Mail server protocol, which can be smtp or smtps
|
Multipart |
relatedPart!
Multipart object
|
BBjNumber |
Retries
Number of retries when sending the email
|
Session |
session!
Session object
|
BBjString |
username$
User name to use for authentication to the mail server
|
Constructor and Description |
---|
Email()
Constructs an Email without specifying any parameters, using those specified in global string variables instead.
|
Email(BBjString mailhost$,
BBjNumber mailport)
Constructs a Email given a host and a port
|
Email(BBjString mailhost$,
BBjNumber mailport,
BBjString username$,
BBjString password$,
BBjString smtp$)
Constructs a Email given a host, port, user name, password, and protocol
|
Modifier and Type | Method and Description |
---|---|
void |
addBcc(BBjString bcc$)
Sets the first recipient or an additional recipient to the blind carbon copy field in an email's header before
the email is sent.
|
void |
addBcc(BBjVector bccAddresses!)
Adds recipients to the "bcc" field in an email's header before the email is sent.
|
void |
addCc(BBjString cc$)
Sets the first recipient or adds an additional recipient to the "cc" field in an email's header
before the email is sent.
|
void |
addCc(BBjVector ccAddresses!)
Adds recipients to the "cc" field in an email's header before the email is sent.
|
void |
addData(BBjString data$,
BBjString mime$)
Adds data to the body of the message allowing the mime type to be specified.
|
void |
addData(FileInputStream fis!,
BBjString mime$)
Adds data to the body of the message allowing the mime type to be specified.
|
void |
addFile(BBjString filename$)
Adds a file attachment to the email message
|
void |
addFile(BBjString filename$,
BBjString contentID$)
Adds a file attachment to the email message
|
void |
addFile(BBjString filename$,
BBjString contentID$,
BBjString mime$)
Adds a file attachment to the email message
|
void |
addImageInline(BBjString filename$,
BBjString contentID$,
BBjString mime$)
Adds an image to the email in such a way that it can be inlined into the HTML content.
|
void |
addText(BBjString text$)
Sets the text for the body of the email message represented by the email object
|
void |
addTo(BBjString to$)
Sets the first recipient or adds an additional recipient to the "to" field in an email's header
before the email is sent.
|
void |
addTo(BBjVector toAddresses!)
Adds recipients to the "to" field in an email's header before the email is sent.
|
void |
send()
Sends an email message once it has been configured.
|
void |
setBcc(BBjString bcc$)
Sets the recipient for the blind carbon copy field in an email's header before the email is sent.
|
void |
setCc(BBjString cc$)
Sets the recipient for the carbon copy field in an email's header before the email is sent.
|
void |
setFrom(BBjString from$)
Sets the "from" field in an email's header before the email is sent.
|
void |
setHeader(BBjString header$,
BBjString value$)
Sets various attributes of the email header
|
void |
setHtml(BBjString html$,
BBjString basedir$)
Sets the html for the email
|
void |
setReplyTo(BBjString replyTo$)
Sets the "reply to" field in an email's header before the email is sent.
|
void |
setSentDate(Date date!)
Sets the "sent date" field in an email's header before the email is sent.
|
void |
setSubject(BBjString subject$)
Sets the subject of the email message represented by the email object
|
void |
setText(BBjString text$)
Sets the text for the body of the email message
|
void |
setTo(BBjString to$)
Sets the "to" field in an email's header before the email is sent.
|
public Session session!
public MimeMessage message!
public Multipart multipart!
public BBjString protocol$
public BBjString mailhost$
public BBjNumber mailport
public BBjString username$
public BBjString password$
public Multipart relatedPart!
public BBjNumber Retries
public Email()
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.public Email(BBjString mailhost$, BBjNumber mailport)
mailhost$
- Mail server hostmailport$
- Mail server portpublic Email(BBjString mailhost$, BBjNumber mailport, BBjString username$, BBjString password$, BBjString smtp$)
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 setSentDate(Date date!)
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$)
subject$
- Subject of emailpublic void setFrom(BBjString from$)
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 setReplyTo(BBjString replyTo$)
This method is optional. Replies will be directed to the from address if this value is not set
replyTo$
- Reply to email addresspublic void setTo(BBjString to$)
This method only supports one email address. Add additional recipients using the addTo() method.
to$
- To email addresspublic void addTo(BBjString to$)
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!)
toAddresses!
- BBjVector of email addresses to addpublic void setCc(BBjString cc$)
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 addCc(BBjString cc$)
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!)
ccAddresses!
- BBjVector of email addresses to addpublic void setBcc(BBjString bcc$)
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 addBcc(BBjString bcc$)
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!)
bccAddresses!
- BBjVector of email addresses to addpublic void setText(BBjString text$)
Alias of addText(). Can be called multiple times to add multiple text parts to the email message.
text$
- Text to setpublic void addText(BBjString text$)
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 addData(BBjString data$, BBjString mime$)
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$)
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 setHtml(BBjString html$, BBjString basedir$)
html$
- HTML formatted string to add to the emailbasedir$
- Specifies the base directory to find HTML referenced files such as imagespublic void addFile(BBjString filename$)
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$)
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$)
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$)
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 setHeader(BBjString header$, BBjString value$)
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 send()
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.