public class ImageHtmlEmail extends HtmlEmail
Small wrapper class on top of HtmlEmail which encapsulates the required logic to retrieve images that are contained in "<img src=../>" elements in the HTML code. This is done by replacing all img-src-elements with "cid:"-entries and embedding images in the email.
For local files the class tries to either load them via an absolute path or - if available - use a relative path starting from a base directory. For files that are not found locally, the implementation tries to download the element and link it in.
The image loading is done by an instance of DataSourceResolver
which has to be provided by the caller.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
REGEX_IMG_SRC
Regexp for extracting
<img> tags |
static java.lang.String |
REGEX_SCRIPT_SRC
regexp for extracting
<script> tags |
CID_LENGTH
ATTACHMENTS, CONTENT_TYPE, EMAIL_BODY, EMAIL_SUBJECT, FILE_SERVER, ISO_8859_1, KOI8_R, MAIL_DEBUG, MAIL_HOST, MAIL_PORT, MAIL_SMTP_AUTH, MAIL_SMTP_CONNECTIONTIMEOUT, MAIL_SMTP_FROM, MAIL_SMTP_PASSWORD, MAIL_SMTP_SOCKET_FACTORY_CLASS, MAIL_SMTP_SOCKET_FACTORY_FALLBACK, MAIL_SMTP_SOCKET_FACTORY_PORT, MAIL_SMTP_TIMEOUT, MAIL_SMTP_USER, MAIL_TRANSPORT_PROTOCOL, MAIL_TRANSPORT_TLS, RECEIVER_EMAIL, RECEIVER_NAME, SENDER_EMAIL, SENDER_NAME, SMTP, TEXT_HTML, TEXT_PLAIN, US_ASCII
Constructor and Description |
---|
ImageHtmlEmail() |
Modifier and Type | Method and Description |
---|---|
void |
buildMimeMessage()
Does the work of actually building the MimeMessage.
|
DataSourceResolver |
getDataSourceResolver()
Get the data source resolver.
|
void |
setDataSourceResolver(DataSourceResolver dataSourceResolver)
Set the data source resolver.
|
embed, embed, embed, embed, embed, embed, setHtmlMsg, setMsg, setTextMsg
addPart, addPart, addPart, attach, attach, attach, attach, attach, attach, getSubType, isBoolHasAttachments, setBoolHasAttachments, setSubType
addBcc, addBcc, addBcc, addBcc, addCc, addCc, addCc, addCc, addHeader, addReplyTo, addReplyTo, addReplyTo, addTo, addTo, addTo, addTo, getBccAddresses, getBounceAddress, getCcAddresses, getFromAddress, getHeader, getHeaders, getHostName, getMailSession, getMimeMessage, getReplyToAddresses, getSentDate, getSmtpPort, getSocketConnectionTimeout, getSocketTimeout, getSslSmtpPort, getSubject, getToAddresses, isSendPartial, isSSL, isSSLCheckServerIdentity, isSSLOnConnect, isStartTLSEnabled, isStartTLSRequired, isTLS, send, sendMimeMessage, setAuthentication, setAuthenticator, setBcc, setBounceAddress, setCc, setCharset, setContent, setContent, setDebug, setFrom, setFrom, setFrom, setHeaders, setHostName, setMailSession, setMailSessionFromJNDI, setPopBeforeSmtp, setReplyTo, setSendPartial, setSentDate, setSmtpPort, setSocketConnectionTimeout, setSocketTimeout, setSSL, setSSLCheckServerIdentity, setSSLOnConnect, setSslSmtpPort, setStartTLSEnabled, setStartTLSRequired, setSubject, setTLS, setTo, updateContentType
public static final java.lang.String REGEX_IMG_SRC
<img>
tagspublic static final java.lang.String REGEX_SCRIPT_SRC
<script>
tagspublic DataSourceResolver getDataSourceResolver()
public void setDataSourceResolver(DataSourceResolver dataSourceResolver)
dataSourceResolver
- the resolverpublic void buildMimeMessage() throws EmailException
buildMimeMessage
in class HtmlEmail
EmailException
- building the MimeMessage failedHtmlEmail.buildMimeMessage()
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"