Package org.apache.commons.mail2.jakarta
Class ImageHtmlEmail
java.lang.Object
org.apache.commons.mail2.jakarta.Email
org.apache.commons.mail2.jakarta.MultiPartEmail
org.apache.commons.mail2.jakarta.HtmlEmail
org.apache.commons.mail2.jakarta.ImageHtmlEmail
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.
- Since:
- 1.3
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Regexp for extracting<img>
tagsstatic final String
Regexp for extracting<script>
tagsFields inherited from class org.apache.commons.mail2.jakarta.HtmlEmail
CID_LENGTH
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Does the work of actually building the MimeMessage.Gets the data source resolver.void
setDataSourceResolver
(DataSourceResolver dataSourceResolver) Sets the data source resolver.Methods inherited from class org.apache.commons.mail2.jakarta.HtmlEmail
embed, embed, embed, embed, embed, embed, getHtml, getText, setHtmlMsg, setMsg, setTextMsg
Methods inherited from class org.apache.commons.mail2.jakarta.MultiPartEmail
addPart, addPart, addPart, attach, attach, attach, attach, attach, attach, attach, createBodyPart, createMimeMultipart, getContainer, getPrimaryBodyPart, getSubType, init, isBoolHasAttachments, isInitialized, setBoolHasAttachments, setInitialized, setSubType
Methods inherited from class org.apache.commons.mail2.jakarta.Email
addBcc, addBcc, addBcc, addBcc, addCc, addCc, addCc, addCc, addHeader, addReplyTo, addReplyTo, addReplyTo, addTo, addTo, addTo, addTo, createMimeMessage, getAuthenticator, getBccAddresses, getBounceAddress, getCcAddresses, getCharsetName, getContent, getContentType, getEmailBody, getFromAddress, getHeader, getHeaders, getHostName, getMailSession, getMessage, getMimeMessage, getPopHost, getPopPassword, getPopUserName, getReplyToAddresses, getSentDate, getSmtpPort, getSocketConnectionTimeout, getSocketTimeout, getSslSmtpPort, getSubject, getToAddresses, isDebug, isPopBeforeSmtp, isSendPartial, isSSLCheckServerIdentity, isSSLOnConnect, isStartTLSEnabled, isStartTLSRequired, send, sendMimeMessage, setAuthentication, setAuthenticator, setBcc, setBounceAddress, setCc, setCharset, setContent, setContent, setContent, setContentType, setDebug, setFrom, setFrom, setFrom, setFromAddress, setHeaders, setHostName, setMailSession, setMailSessionFromJNDI, setMessage, setPopBeforeSmtp, setPopBeforeSmtp, setPopHost, setPopPassword, setPopUsername, setReplyTo, setSendPartial, setSentDate, setSmtpPort, setSocketConnectionTimeout, setSocketTimeout, setSSLCheckServerIdentity, setSSLOnConnect, setSslSmtpPort, setStartTLSEnabled, setStartTLSRequired, setSubject, setTo, toInternetAddressArray, updateContentType
-
Field Details
-
REGEX_IMG_SRC
Regexp for extracting<img>
tags- See Also:
-
REGEX_SCRIPT_SRC
Regexp for extracting<script>
tags- See Also:
-
-
Constructor Details
-
ImageHtmlEmail
public ImageHtmlEmail()Constructs a new instance.
-
-
Method Details
-
buildMimeMessage
Does the work of actually building the MimeMessage.- Overrides:
buildMimeMessage
in classHtmlEmail
- Throws:
EmailException
- building the MimeMessage failed- See Also:
-
getDataSourceResolver
Gets the data source resolver.- Returns:
- the resolver
-
setDataSourceResolver
Sets the data source resolver.- Parameters:
dataSourceResolver
- the resolver
-