org.springframework.mail
Class SimpleMailMessage

java.lang.Object
  extended by org.springframework.mail.SimpleMailMessage
All Implemented Interfaces:
java.io.Serializable, MailMessage

public class SimpleMailMessage
extends java.lang.Object
implements MailMessage, java.io.Serializable

Models a simple mail message, including data such as the from, to, cc, subject, and text fields.

Consider JavaMailSender and JavaMail MimeMessages for creating more sophisticated messages, for example messages with attachments, special character encodings, or personal names that accompany mail addresses.

Since:
10.09.2003
Author:
Dmitriy Kopylenko, Juergen Hoeller
See Also:
MailSender, JavaMailSender, MimeMessagePreparator, MimeMessageHelper, MimeMailMessage, Serialized Form

Field Summary
private  java.lang.String[] bcc
           
private  java.lang.String[] cc
           
private  java.lang.String from
           
private  java.lang.String replyTo
           
private  java.util.Date sentDate
           
private  java.lang.String subject
           
private  java.lang.String text
           
private  java.lang.String[] to
           
 
Constructor Summary
SimpleMailMessage()
          Create a new SimpleMailMessage.
SimpleMailMessage(SimpleMailMessage original)
          Copy constructor for creating a new SimpleMailMessage from the state of an existing SimpleMailMessage instance.
 
Method Summary
private static java.lang.String[] copy(java.lang.String[] state)
           
 void copyTo(MailMessage target)
          Copy the contents of this message to the given target message.
 boolean equals(java.lang.Object other)
           
 java.lang.String[] getBcc()
           
 java.lang.String[] getCc()
           
 java.lang.String getFrom()
           
 java.lang.String getReplyTo()
           
 java.util.Date getSentDate()
           
 java.lang.String getSubject()
           
 java.lang.String getText()
           
 java.lang.String[] getTo()
           
 int hashCode()
           
 void setBcc(java.lang.String bcc)
           
 void setBcc(java.lang.String[] bcc)
           
 void setCc(java.lang.String cc)
           
 void setCc(java.lang.String[] cc)
           
 void setFrom(java.lang.String from)
           
 void setReplyTo(java.lang.String replyTo)
           
 void setSentDate(java.util.Date sentDate)
           
 void setSubject(java.lang.String subject)
           
 void setText(java.lang.String text)
           
 void setTo(java.lang.String to)
           
 void setTo(java.lang.String[] to)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

from

private java.lang.String from

replyTo

private java.lang.String replyTo

to

private java.lang.String[] to

cc

private java.lang.String[] cc

bcc

private java.lang.String[] bcc

sentDate

private java.util.Date sentDate

subject

private java.lang.String subject

text

private java.lang.String text
Constructor Detail

SimpleMailMessage

public SimpleMailMessage()
Create a new SimpleMailMessage.


SimpleMailMessage

public SimpleMailMessage(SimpleMailMessage original)
Copy constructor for creating a new SimpleMailMessage from the state of an existing SimpleMailMessage instance.

Throws:
java.lang.IllegalArgumentException - if the supplied message is null
Method Detail

setFrom

public void setFrom(java.lang.String from)
Specified by:
setFrom in interface MailMessage

getFrom

public java.lang.String getFrom()

setReplyTo

public void setReplyTo(java.lang.String replyTo)
Specified by:
setReplyTo in interface MailMessage

getReplyTo

public java.lang.String getReplyTo()

setTo

public void setTo(java.lang.String to)
Specified by:
setTo in interface MailMessage

setTo

public void setTo(java.lang.String[] to)
Specified by:
setTo in interface MailMessage

getTo

public java.lang.String[] getTo()

setCc

public void setCc(java.lang.String cc)
Specified by:
setCc in interface MailMessage

setCc

public void setCc(java.lang.String[] cc)
Specified by:
setCc in interface MailMessage

getCc

public java.lang.String[] getCc()

setBcc

public void setBcc(java.lang.String bcc)
Specified by:
setBcc in interface MailMessage

setBcc

public void setBcc(java.lang.String[] bcc)
Specified by:
setBcc in interface MailMessage

getBcc

public java.lang.String[] getBcc()

setSentDate

public void setSentDate(java.util.Date sentDate)
Specified by:
setSentDate in interface MailMessage

getSentDate

public java.util.Date getSentDate()

setSubject

public void setSubject(java.lang.String subject)
Specified by:
setSubject in interface MailMessage

getSubject

public java.lang.String getSubject()

setText

public void setText(java.lang.String text)
Specified by:
setText in interface MailMessage

getText

public java.lang.String getText()

copyTo

public void copyTo(MailMessage target)
Copy the contents of this message to the given target message.

Parameters:
target - the MailMessage to copy to
Throws:
java.lang.IllegalArgumentException - if the supplied target is null

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

copy

private static java.lang.String[] copy(java.lang.String[] state)