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 voidaddHeader(String p_strName, String p_strValue)voidaddRecipient(javax.mail.Message.RecipientType p_rcpType, String p_strAddress)voidaddRecipient(javax.mail.Message.RecipientType p_rcpType, javax.mail.internet.InternetAddress p_address)voidaddRecipientBcc(String p_strAddress)voidaddRecipientBcc(javax.mail.internet.InternetAddress p_address)voidaddRecipientCc(String p_strAddress)voidaddRecipientCc(javax.mail.internet.InternetAddress p_address)voidaddRecipientReplyTo(String p_strAddress)voidaddRecipientReplyTo(javax.mail.internet.InternetAddress p_address)voidaddRecipients(javax.mail.Message.RecipientType p_rcpType, Collection<String> p_addresses)voidaddRecipientsBcc(Collection<String> p_addresses)voidaddRecipientsCc(Collection<String> p_addresses)voidaddRecipientsReplyTo(Collection<String> p_addresses)voidaddRecipientsTo(Collection<String> p_addresses)voidaddRecipientTo(String p_strAddress)voidaddRecipientTo(javax.mail.internet.InternetAddress p_address)voidattachFile(de.uplanet.lucy.server.mail.AttachmentFile p_attachment)voidattachFile(String p_strPath, String p_strFileName, String p_strContentType)voidattachRelatedFile(de.uplanet.lucy.server.mail.AttachmentFile p_attachment)voidattachRelatedFile(String p_strPath, String p_strFileName, String p_strContentType, String p_strContentId)voidclearContentAndAttachments()Clears the content previously set withsetContent(String, String)as well as all attachments.voidcommit()MailBuildercreateClone()booleanhasRecipients()booleanhasRecipientsBcc()booleanhasRecipientsCc()booleanhasRecipientsReplyTo()booleanhasRecipientsTo()voidrollback()Stringsend()This method creates a MIME message and stores the message as file in the pickup folder.voidsetAutoCommit(boolean p_bAutoCommit)voidsetContent(String p_strContent, String p_strContentType)voidsetFrom(String p_strFrom)voidsetFrom(javax.mail.internet.InternetAddress p_addressFrom)voidsetSubject(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_strAddressisnullor 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.MessagingExceptionIOExceptionInterruptedException
-
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()
-
-