de.uplanet.lucy.server.mail
Class MailBuilder

java.lang.Object
  extended by de.uplanet.lucy.server.mail.MailBuilder

public final class MailBuilder
extends java.lang.Object

The MailBuilder class creates MIME messages with different content-types, manages attachments, and inline pictures using HTML mail.

The mail will be stored in the portal's mailroot/pickup folder.

Version:
$Revision: 88254 $

Constructor Summary
MailBuilder(java.io.File p_dirTmp, java.io.File p_dirPickup, javax.mail.internet.InternetAddress p_addressFromFallback)
           
 
Method Summary
 void addHeader(java.lang.String p_strName, java.lang.String p_strValue)
           
 void addRecipient(javax.mail.Message.RecipientType p_rcpType, javax.mail.internet.InternetAddress p_address)
           
 void addRecipient(javax.mail.Message.RecipientType p_rcpType, java.lang.String p_strAddress)
           
 void addRecipientBcc(javax.mail.internet.InternetAddress p_address)
           
 void addRecipientBcc(java.lang.String p_strAddress)
           
 void addRecipientCc(javax.mail.internet.InternetAddress p_address)
           
 void addRecipientCc(java.lang.String p_strAddress)
           
 void addRecipients(javax.mail.Message.RecipientType p_rcpType, java.util.Collection<java.lang.String> p_addresses)
           
 void addRecipientsBcc(java.util.Collection<java.lang.String> p_addresses)
           
 void addRecipientsCc(java.util.Collection<java.lang.String> p_addresses)
           
 void addRecipientsTo(java.util.Collection<java.lang.String> p_addresses)
           
 void addRecipientTo(javax.mail.internet.InternetAddress p_address)
           
 void addRecipientTo(java.lang.String p_strAddress)
           
 void attachFile(de.uplanet.lucy.server.mail.AttachmentFile p_attachment)
           
 void attachFile(java.lang.String p_strPath, java.lang.String p_strFileName, java.lang.String p_strContentType)
           
 void attachRelatedFile(de.uplanet.lucy.server.mail.AttachmentFile p_attachment)
           
 void attachRelatedFile(java.lang.String p_strPath, java.lang.String p_strFileName, java.lang.String p_strContentType, java.lang.String p_strContentId)
           
 void clearContentAndAttachments()
          Clears the content previously set with setContent(String, String) as well as all attachments.
 void commit()
           
 MailBuilder createClone()
           
 boolean hasRecipients()
           
 boolean hasRecipientsBcc()
           
 boolean hasRecipientsCc()
           
 boolean hasRecipientsTo()
           
 void rollback()
           
 java.lang.String send()
          This method creates a mime message and stores the message as file in the pickup folder defined in UpSmtpConfig.
 void setAutoCommit(boolean p_bAutoCommit)
           
 void setContent(java.lang.String p_strContent, java.lang.String p_strContentType)
           
 void setFrom(javax.mail.internet.InternetAddress p_addressFrom)
           
 void setFrom(java.lang.String p_strFrom)
           
 void setSubject(java.lang.String p_strSubject)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MailBuilder

public MailBuilder(java.io.File p_dirTmp,
                   java.io.File p_dirPickup,
                   javax.mail.internet.InternetAddress p_addressFromFallback)
Method Detail

setAutoCommit

public void setAutoCommit(boolean p_bAutoCommit)

addHeader

public void addHeader(java.lang.String p_strName,
                      java.lang.String p_strValue)

hasRecipients

public boolean hasRecipients()

hasRecipientsTo

public boolean hasRecipientsTo()

hasRecipientsCc

public boolean hasRecipientsCc()

hasRecipientsBcc

public boolean hasRecipientsBcc()

addRecipient

public void addRecipient(javax.mail.Message.RecipientType p_rcpType,
                         java.lang.String p_strAddress)
                  throws javax.mail.internet.AddressException
Throws:
javax.mail.internet.AddressException - If the given address is not a valid Internet mail address.
java.lang.IllegalArgumentException - If p_strAddress is null or empty.

addRecipient

public void addRecipient(javax.mail.Message.RecipientType p_rcpType,
                         javax.mail.internet.InternetAddress p_address)

addRecipientTo

public void addRecipientTo(java.lang.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(java.util.Collection<java.lang.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(java.lang.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(java.util.Collection<java.lang.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(java.lang.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(java.util.Collection<java.lang.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,
                          java.util.Collection<java.lang.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 java.lang.String send()
                      throws de.uplanet.lucy.server.mail.MailServiceNotAvailableException,
                             java.io.FileNotFoundException,
                             javax.mail.MessagingException,
                             java.io.IOException,
                             java.security.NoSuchAlgorithmException,
                             java.lang.ClassNotFoundException,
                             java.sql.SQLException,
                             java.lang.InterruptedException
This method creates a mime message and stores the message as file in the pickup folder defined in UpSmtpConfig.

Returns:
the name of the created mail file
Throws:
de.uplanet.lucy.server.mail.MailServiceNotAvailableException - If the mail service is not enabled.
java.io.FileNotFoundException
javax.mail.MessagingException
java.io.IOException
java.security.NoSuchAlgorithmException
java.lang.ClassNotFoundException
java.sql.SQLException
java.lang.InterruptedException

commit

public void commit()
            throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

rollback

public void rollback()
              throws java.lang.Exception
Throws:
java.lang.Exception

setContent

public void setContent(java.lang.String p_strContent,
                       java.lang.String p_strContentType)
Parameters:
p_strContent -
p_strContentType - void

attachFile

public void attachFile(de.uplanet.lucy.server.mail.AttachmentFile p_attachment)

attachFile

public void attachFile(java.lang.String p_strPath,
                       java.lang.String p_strFileName,
                       java.lang.String p_strContentType)

attachRelatedFile

public void attachRelatedFile(java.lang.String p_strPath,
                              java.lang.String p_strFileName,
                              java.lang.String p_strContentType,
                              java.lang.String p_strContentId)

attachRelatedFile

public void attachRelatedFile(de.uplanet.lucy.server.mail.AttachmentFile p_attachment)

clearContentAndAttachments

public void clearContentAndAttachments()
Clears the content previously set with setContent(String, String) as well as all attachments.

For internal use only.


setFrom

public void setFrom(java.lang.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(java.lang.String p_strSubject)

createClone

public MailBuilder createClone()


Last updated: 2011-01-27
Copyright 2000-2010 United Planet. All Rights Reserved.