Package de.uplanet.lucy.server.mail
Class MailBuilder
- java.lang.Object
-
- de.uplanet.lucy.server.mail.MailBuilder
-
public final class MailBuilder extends Object
The MailBuilder class creates MIME messages with different content-types, manages attachments, and inline pictures using HTML mail.
-
-
Constructor Summary
Constructors Constructor Description MailBuilder(Path p_dirTmp, Path p_dirPickup, javax.mail.internet.InternetAddress p_addressFromFallback)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addHeader(String p_strName, String p_strValue)
void
addRecipient(javax.mail.Message.RecipientType p_rcpType, String p_strAddress)
void
addRecipient(javax.mail.Message.RecipientType p_rcpType, javax.mail.internet.InternetAddress p_address)
void
addRecipientBcc(String p_strAddress)
void
addRecipientBcc(javax.mail.internet.InternetAddress p_address)
void
addRecipientCc(String p_strAddress)
void
addRecipientCc(javax.mail.internet.InternetAddress p_address)
void
addRecipientReplyTo(String p_strAddress)
void
addRecipientReplyTo(javax.mail.internet.InternetAddress p_address)
void
addRecipients(javax.mail.Message.RecipientType p_rcpType, Collection<String> p_addresses)
void
addRecipientsBcc(Collection<String> p_addresses)
void
addRecipientsCc(Collection<String> p_addresses)
void
addRecipientsReplyTo(Collection<String> p_addresses)
void
addRecipientsTo(Collection<String> p_addresses)
void
addRecipientTo(String p_strAddress)
void
addRecipientTo(javax.mail.internet.InternetAddress p_address)
void
attachFile(de.uplanet.lucy.server.mail.AttachmentFile p_attachment)
void
attachFile(String p_strPath, String p_strFileName, String p_strContentType)
void
attachRelatedFile(de.uplanet.lucy.server.mail.AttachmentFile p_attachment)
void
attachRelatedFile(String p_strPath, String p_strFileName, String p_strContentType, String p_strContentId)
void
clearContentAndAttachments()
Clears the content previously set withsetContent(String, String)
as well as all attachments.void
commit()
MailBuilder
createClone()
boolean
hasRecipients()
boolean
hasRecipientsBcc()
boolean
hasRecipientsCc()
boolean
hasRecipientsReplyTo()
boolean
hasRecipientsTo()
void
rollback()
String
send()
This method creates a MIME message and stores the message as file in the pickup folder.void
setAutoCommit(boolean p_bAutoCommit)
void
setContent(String p_strContent, String p_strContentType)
void
setFrom(String p_strFrom)
void
setFrom(javax.mail.internet.InternetAddress p_addressFrom)
void
setSubject(String p_strSubject)
-
-
-
Method Detail
-
setAutoCommit
public void setAutoCommit(boolean p_bAutoCommit)
-
hasRecipients
public boolean hasRecipients()
-
hasRecipientsTo
public boolean hasRecipientsTo()
-
hasRecipientsCc
public boolean hasRecipientsCc()
-
hasRecipientsBcc
public boolean hasRecipientsBcc()
-
hasRecipientsReplyTo
public boolean hasRecipientsReplyTo()
-
addRecipient
public void addRecipient(javax.mail.Message.RecipientType p_rcpType, String p_strAddress) throws javax.mail.internet.AddressException
- Throws:
javax.mail.internet.AddressException
- If the given address is not a valid Internet mail address.IllegalArgumentException
- Ifp_strAddress
isnull
or empty.
-
addRecipient
public void addRecipient(javax.mail.Message.RecipientType p_rcpType, javax.mail.internet.InternetAddress p_address)
-
addRecipientTo
public void addRecipientTo(String p_strAddress) throws javax.mail.internet.AddressException
- Throws:
javax.mail.internet.AddressException
-
addRecipientTo
public void addRecipientTo(javax.mail.internet.InternetAddress p_address)
-
addRecipientsTo
public void addRecipientsTo(Collection<String> p_addresses) throws javax.mail.internet.AddressException
- Parameters:
p_addresses
- A collection of e-mail addresses.- Throws:
javax.mail.internet.AddressException
- If the given address is not a valid Internet mail address.
-
addRecipientCc
public void addRecipientCc(String p_strAddress) throws javax.mail.internet.AddressException
- Throws:
javax.mail.internet.AddressException
-
addRecipientCc
public void addRecipientCc(javax.mail.internet.InternetAddress p_address)
-
addRecipientsCc
public void addRecipientsCc(Collection<String> p_addresses) throws javax.mail.internet.AddressException
- Parameters:
p_addresses
- A collection of e-mail addresses.- Throws:
javax.mail.internet.AddressException
- If the given address is not a valid Internet mail address.
-
addRecipientBcc
public void addRecipientBcc(String p_strAddress) throws javax.mail.internet.AddressException
- Throws:
javax.mail.internet.AddressException
-
addRecipientBcc
public void addRecipientBcc(javax.mail.internet.InternetAddress p_address)
-
addRecipientsBcc
public void addRecipientsBcc(Collection<String> p_addresses) throws javax.mail.internet.AddressException
- Parameters:
p_addresses
- A collection of e-mail addresses.- Throws:
javax.mail.internet.AddressException
- If the given address is not a valid Internet mail address.
-
addRecipientReplyTo
public void addRecipientReplyTo(String p_strAddress) throws javax.mail.internet.AddressException
- Throws:
javax.mail.internet.AddressException
-
addRecipientReplyTo
public void addRecipientReplyTo(javax.mail.internet.InternetAddress p_address)
-
addRecipientsReplyTo
public void addRecipientsReplyTo(Collection<String> p_addresses) throws javax.mail.internet.AddressException
- Parameters:
p_addresses
- A collection of e-mail addresses.- Throws:
javax.mail.internet.AddressException
- If the given address is not a valid Internet mail address.
-
addRecipients
public void addRecipients(javax.mail.Message.RecipientType p_rcpType, Collection<String> p_addresses) throws javax.mail.internet.AddressException
- Parameters:
p_rcpType
- The recipient type.p_addresses
- A collection of mail addresses.- Throws:
javax.mail.internet.AddressException
- If one of the given addresses is not a valid Internet mail address.
-
send
public String send() throws javax.mail.MessagingException, IOException, InterruptedException
This method creates a MIME message and stores the message as file in the pickup folder.- Returns:
- The name of the mail file created.
- Throws:
javax.mail.MessagingException
IOException
InterruptedException
-
commit
public void commit() throws InterruptedException
- Throws:
InterruptedException
-
rollback
public void rollback()
-
setContent
public void setContent(String p_strContent, String p_strContentType)
- Parameters:
p_strContent
-p_strContentType
- void
-
attachFile
public void attachFile(de.uplanet.lucy.server.mail.AttachmentFile p_attachment)
-
attachRelatedFile
public void attachRelatedFile(String p_strPath, String p_strFileName, String p_strContentType, String p_strContentId)
-
attachRelatedFile
public void attachRelatedFile(de.uplanet.lucy.server.mail.AttachmentFile p_attachment)
-
clearContentAndAttachments
public void clearContentAndAttachments()
Clears the content previously set withsetContent(String, String)
as well as all attachments.For internal use only.
-
setFrom
public void setFrom(String p_strFrom) throws javax.mail.internet.AddressException
- Throws:
javax.mail.internet.AddressException
-
setFrom
public void setFrom(javax.mail.internet.InternetAddress p_addressFrom)
-
setSubject
public void setSubject(String p_strSubject)
-
createClone
public MailBuilder createClone()
-
-