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 String |
REGEX_IMG_SRC
Regexp for extracting
<img> tags |
static String |
REGEX_SCRIPT_SRC
regexp for extracting
<script> tags |
CID_LENGTH, html, inlineEmbeds, inlineImages, text
ATTACHMENTS, authenticator, bccList, bounceAddress, ccList, charset, content, CONTENT_TYPE, contentType, debug, EMAIL_BODY, EMAIL_SUBJECT, emailBody, FILE_SERVER, fromAddress, headers, hostName, 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, message, popBeforeSmtp, popHost, popPassword, popUsername, RECEIVER_EMAIL, RECEIVER_NAME, replyList, SENDER_EMAIL, SENDER_NAME, sentDate, SMTP, smtpPort, socketConnectionTimeout, socketTimeout, ssl, sslSmtpPort, subject, TEXT_HTML, TEXT_PLAIN, tls, toList, 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, createBodyPart, createMimeMultipart, getContainer, getPrimaryBodyPart, getSubType, init, isBoolHasAttachments, isInitialized, setBoolHasAttachments, setInitialized, setSubType
addBcc, addBcc, addBcc, addBcc, addCc, addCc, addCc, addCc, addHeader, addReplyTo, addReplyTo, addReplyTo, addTo, addTo, addTo, addTo, createMimeMessage, 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, toInternetAddressArray, updateContentType
public static final String REGEX_IMG_SRC
<img>
tagspublic static final 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 © 2001–2017 The Apache Software Foundation. All rights reserved.