org.mentawai.mail
Class MultiPartEmail

java.lang.Object
  extended by org.mentawai.mail.Email
      extended by org.mentawai.mail.MultiPartEmail
Direct Known Subclasses:
HtmlEmail

public class MultiPartEmail
extends Email

A multipart email.

This class is used to send multi-part internet email like messages with attachments.

To create a multi-part email, call the default constructor and then you can call setMsg() to set the message and call the different attach() methods.

Version:
$Id: MultiPartEmail.java,v 1.1 2006/03/02 17:11:41 soliveira Exp $
Author:
Quinton McCombs, Jon S. Stevens, Frank Y. Kim, Brett McLaughlin, Regis Koenig, Corey Scott

Field Summary
 
Fields inherited from class org.mentawai.mail.Email
ATTACHMENTS, authenticator, bccList, bounceAddress, ccList, charset, content, CONTENT_TYPE, contentType, debug, EMAIL_BODY, EMAIL_SUBJECT, emailBody, FILE_SERVER, fromAddress, headers, hostName, ISO_8859_1, KOI8_R, MAIL_DEBUG, MAIL_FACTORY_CLASS, MAIL_FACTORY_FALLBACK, MAIL_FACTORY_PORT, MAIL_HOST, MAIL_PORT, MAIL_SMTP_AUTH, MAIL_SMTP_FROM, MAIL_TRANSPORT_PROTOCOL, message, popBeforeSmtp, popHost, popPassword, popUsername, RECEIVER_EMAIL, RECEIVER_NAME, replyList, SENDER_EMAIL, SENDER_NAME, sentDate, SMTP, smtpPort, ssl_connection, subject, TEXT_HTML, TEXT_PLAIN, toList, US_ASCII
 
Constructor Summary
MultiPartEmail()
           
 
Method Summary
 Email addPart(javax.mail.internet.MimeMultipart multipart)
          Add a new part to the email.
 Email addPart(javax.mail.internet.MimeMultipart multipart, int index)
          Add a new part to the email.
 Email addPart(String content, String contentType)
          Add a new part to the email.
 MultiPartEmail attach(DataSource ds, String name, String description)
          Attach a file specified as a DataSource interface.
 MultiPartEmail attach(DataSource ds, String name, String description, String disposition)
          Attach a file specified as a DataSource interface.
 MultiPartEmail attach(EmailAttachment attachment)
          Attach an EmailAttachement.
 MultiPartEmail attach(URL url, String name, String description)
          Attach a file located by its URL.
 MultiPartEmail attach(URL url, String name, String description, String disposition)
          Attach a file located by its URL.
protected  javax.mail.internet.MimeMultipart getContainer()
          Gets the message container.
protected  javax.mail.internet.MimeBodyPart getPrimaryBodyPart()
          Gets first body part of the message.
 String getSubType()
          Get the MIME subtype of the email.
protected  void init()
          Initialize the multipart email.
 boolean isBoolHasAttachments()
           
 void send()
          Sends the mail message
 void setBoolHasAttachments(boolean b)
           
 Email setMsg(String msg)
          Set the message of the email.
 void setSubType(String aSubType)
          Set the MIME subtype of the email.
 
Methods inherited from class org.mentawai.mail.Email
addBcc, addBcc, addCc, addCc, addHeader, addReplyTo, addReplyTo, addTo, addTo, getMailSession, getSentDate, removeBcc, removeCc, removeTo, send, sendLater, sendLater, sendLater, setAuthentication, setAuthenticator, setBcc, setBounceAddress, setCc, setCharset, setContent, setContent, setDebug, setDefaultAuthentication, setDefaultBounceAddress, setDefaultCharset, setDefaultFrom, setDefaultHostName, setDefaultPort, setDefaultPort, setDefaultSslConnection, setFactoryFallBack, setFrom, setFrom, setHeaders, setHostName, setMailSession, setPopBeforeSmtp, setSendEmail, setSentDate, setSmtpPort, setSslConnection, setSSLConnection, setSubject, setTo, toInternetAddressArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiPartEmail

public MultiPartEmail()
Method Detail

setSubType

public void setSubType(String aSubType)
Set the MIME subtype of the email.

Parameters:
aSubType - MIME subtype of the email

getSubType

public String getSubType()
Get the MIME subtype of the email.

Returns:
MIME subtype of the email

addPart

public Email addPart(String content,
                     String contentType)
              throws EmailException
Add a new part to the email.

Parameters:
content - The content.
contentType - The content type.
Returns:
An Email.
Throws:
EmailException - see javax.mail.internet.MimeBodyPart for defintions

addPart

public Email addPart(javax.mail.internet.MimeMultipart multipart)
              throws EmailException
Add a new part to the email.

Parameters:
multipart - The MimeMultipart.
Returns:
An Email.
Throws:
EmailException - see javax.mail.internet.MimeBodyPart for defintions

addPart

public Email addPart(javax.mail.internet.MimeMultipart multipart,
                     int index)
              throws EmailException
Add a new part to the email.

Parameters:
multipart - The part to add.
index - The index to add at.
Returns:
The email.
Throws:
EmailException - An error occured while adding the part.

init

protected void init()
Initialize the multipart email.


setMsg

public Email setMsg(String msg)
             throws EmailException
Set the message of the email.

Specified by:
setMsg in class Email
Parameters:
msg - A String.
Returns:
An Email.
Throws:
EmailException - see javax.mail.internet.MimeBodyPart for defintions

send

public void send()
          throws EmailException
Sends the mail message

Overrides:
send in class Email
Throws:
EmailException - see javax.mail.internet.MimeBodyPart for defintions

attach

public MultiPartEmail attach(EmailAttachment attachment)
                      throws EmailException
Attach an EmailAttachement.

Parameters:
attachment - An EmailAttachment.
Returns:
A MultiPartEmail.
Throws:
EmailException - see javax.mail.internet.MimeBodyPart for defintions

attach

public MultiPartEmail attach(URL url,
                             String name,
                             String description)
                      throws EmailException
Attach a file located by its URL. The disposition of the file is set to mixed.

Parameters:
url - The URL of the file (may be any valid URL).
name - The name field for the attachment.
description - A description for the attachment.
Returns:
A MultiPartEmail.
Throws:
EmailException - see javax.mail.internet.MimeBodyPart for defintions

attach

public MultiPartEmail attach(URL url,
                             String name,
                             String description,
                             String disposition)
                      throws EmailException
Attach a file located by its URL.

Parameters:
url - The URL of the file (may be any valid URL).
name - The name field for the attachment.
description - A description for the attachment.
disposition - Either mixed or inline.
Returns:
A MultiPartEmail.
Throws:
EmailException - see javax.mail.internet.MimeBodyPart for defintions

attach

public MultiPartEmail attach(DataSource ds,
                             String name,
                             String description)
                      throws EmailException
Attach a file specified as a DataSource interface.

Parameters:
ds - A DataSource interface for the file.
name - The name field for the attachment.
description - A description for the attachment.
Returns:
A MultiPartEmail.
Throws:
EmailException - see javax.mail.internet.MimeBodyPart for defintions

attach

public MultiPartEmail attach(DataSource ds,
                             String name,
                             String description,
                             String disposition)
                      throws EmailException
Attach a file specified as a DataSource interface.

Parameters:
ds - A DataSource interface for the file.
name - The name field for the attachment.
description - A description for the attachement.
disposition - Either mixed or inline.
Returns:
A MultiPartEmail.
Throws:
EmailException - see javax.mail.internet.MimeBodyPart for defintions

getPrimaryBodyPart

protected javax.mail.internet.MimeBodyPart getPrimaryBodyPart()
                                                       throws javax.mail.MessagingException
Gets first body part of the message.

Returns:
The primary body part.
Throws:
javax.mail.MessagingException - An error occured while getting the primary body part.

getContainer

protected javax.mail.internet.MimeMultipart getContainer()
Gets the message container.

Returns:
The message container.

isBoolHasAttachments

public boolean isBoolHasAttachments()
Returns:
boolHasAttachments

setBoolHasAttachments

public void setBoolHasAttachments(boolean b)
Parameters:
b - boolHasAttachments


Copyright © 2013. All Rights Reserved.