public class MailHelper extends Object
| Constructor and Description |
|---|
MailHelper() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addGreeting()
Can be overridden to add a custom greeting.
|
String |
addImage(String name,
String rurl)
Add a web resource as an image, and return the image's internal ID.
|
MailHelper |
addTo(Address a) |
MailHelper |
addTo(String email) |
protected void |
addTrailer()
Can be overridden to add a default trailer.
|
MailHelper |
append(String s)
Just add verbatim text, without anything else.
|
void |
appendVerbatim(String s)
Append the text without scanning for any kind of embedded links.
|
MailHelper |
b(String s) |
protected InputStream |
getApplicationResource(String name) |
String |
getApplicationURL() |
List<to.etc.webapp.mailer.MailHelper.Attachment> |
getAttachmentList() |
StringBuilder |
getHtmlBuffer() |
String |
getSubject() |
StringBuilder |
getTextBuffer() |
List<Address> |
getTo() |
void |
htmlEndTag(String tag) |
void |
htmlTag(String tag,
String... attrs)
Render a html tag with optional attr=value pairs.
|
void |
htmlText(String text)
Split text into whitespace-separated things, and make sure lines are smaller than MAXLINE.
|
MailHelper |
i(String s) |
MailHelper |
image(to.etc.webapp.mailer.MailHelper.Attachment a,
String name)
Add an image link for a specified attachment.
|
MailHelper |
image(String name,
Class<?> resourceClass,
String resourceName)
Add a class resource as an image.
|
MailHelper |
image(String name,
String rurl)
Add a web resource as an image.
|
MailHelper |
image(String name,
String mime,
File source)
Append an image as an attachment, and embed the image in the HTML stream.
|
MailHelper |
image(String name,
String mime,
String rurl)
Add a web resource as an image.
|
MailHelper |
link(String text,
IIdentifyable<?> inst)
Use the LinkedText mechanism to render a link to some entity.
|
MailHelper |
link(String url,
String text)
Render a link in HTML, embedding "text" in the link.
|
MailHelper |
linkNoText(String url,
String text)
Create a link in html only.
|
MailHelper |
nl() |
MailHelper |
pre(String content) |
void |
send()
Send the message using the
BulkMailer's default instance, using a newly allocated connection. |
void |
send(QDataContext dc)
Send the message using the
BulkMailer using the specified connection. |
void |
send(SmtpTransport transport)
Send the message immediately through the specified transport - only use this if the BulkMailer should
not be used.
|
void |
sendInternal(Object through)
Queue the message for transmission.
|
void |
setApplicationURL(String applicationURL)
Set the root application URL.
|
MailHelper |
setFrom(Address from) |
MailHelper |
setFrom(String from) |
void |
setLinkRenderer(ITextLinkRenderer linkRenderer) |
void |
setRoot(File root) |
MailHelper |
setSubject(String subject) |
void |
start(Address to,
String subject) |
MailHelper |
ttl(String s) |
public void setRoot(File root)
public void htmlTag(String tag, String... attrs)
tag - attrs - public void htmlEndTag(String tag)
public void htmlText(String text)
text - @Nonnull public MailHelper append(@Nonnull String s)
LinkedText into something
that might be edible by email.s - public void appendVerbatim(@Nonnull String s)
s - @Nonnull public MailHelper ttl(@Nonnull String s)
@Nonnull public MailHelper i(String s)
@Nonnull public MailHelper b(String s)
@Nonnull public MailHelper nl()
@Nonnull public MailHelper pre(String content)
@Nonnull public MailHelper link(@Nonnull String url, @Nonnull String text)
text (link)
url - The full URL to link to.text - The link's text.@Nonnull public MailHelper link(@Nonnull String text, @Nonnull IIdentifyable<?> inst)
TextLinkInfo registered for the class.text - inst - @Nonnull public MailHelper linkNoText(String url, String text)
url - text - @Nonnull public MailHelper image(String name, String mime, File source) throws Exception
name - source - Exception@Nonnull public MailHelper image(String name, Class<?> resourceClass, String resourceName) throws Exception
name - resourceClass - resourceName - Exception@Nonnull public MailHelper image(@Nonnull String name, @Nonnull String mime, @Nonnull String rurl) throws Exception
getApplicationResource(String).name - mime - rurl - Exception@Nonnull public MailHelper image(@Nonnull String name, @Nonnull String rurl) throws Exception
getApplicationResource(String).name - rurl - Exception@Nonnull public String addImage(@Nonnull String name, @Nonnull String rurl) throws Exception
getApplicationResource(String).name - rurl - Exceptionpublic MailHelper image(@Nonnull to.etc.webapp.mailer.MailHelper.Attachment a, @Nonnull String name) throws Exception
a - name - Exceptionpublic void send()
throws Exception
BulkMailer's default instance, using a newly allocated connection.Exceptionpublic void send(@Nonnull SmtpTransport transport) throws Exception
transport - Exceptionpublic void send(@Nonnull QDataContext dc) throws Exception
BulkMailer using the specified connection. The message will be sent only
when that connection is commited, storing the data into the database for the BulkMailer to find.dc - Exceptionpublic void sendInternal(@Nullable Object through) throws Exception
Exception@Nonnull public StringBuilder getHtmlBuffer()
@Nonnull public StringBuilder getTextBuffer()
@Nonnull public List<to.etc.webapp.mailer.MailHelper.Attachment> getAttachmentList()
public MailHelper addTo(@Nonnull Address a)
@Nonnull public MailHelper addTo(@Nonnull String email)
@Nonnull public MailHelper setFrom(@Nonnull String from)
@Nonnull public MailHelper setFrom(@Nonnull Address from)
@Nonnull public MailHelper setSubject(@Nonnull String subject)
public void setLinkRenderer(@Nonnull ITextLinkRenderer linkRenderer)
public void setApplicationURL(@Nonnull String applicationURL)
applicationURL - protected void addGreeting()
protected void addTrailer()
throws Exception
ExceptionCopyright © 2017 etc.to. All rights reserved.