java.lang.Object
javax.mail.Message
- All Implemented Interfaces:
- Part
- Direct Known Subclasses:
- MimeMessage
- See Also:
- Top Examples, Source Code
public abstract void addFrom(Address[] addresses)
throws MessagingException
- See Also:
- IllegalStateException, IllegalWriteException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[225]Work around for problem with geting a mail session
By Anonymous on 2004/12/30 17:21:52 Rate
import java.util.Date;
import java.util.Properties;
import javax.naming.*;
import javax.mail.*;
import javax.mail.internet.*;
....
// Local reference to the javax.mail.Session
javax.mail.Session mailSession = null;
try {
Context ctx = new InitialContext ( ) ;
// Get the properties from this bean from the environment. The
// properties were specified in the env-entry tags in the deployment
// descriptor for this bean
Context myEnv = ( Context ) ctx.lookup ( "java:comp/env" ) ;
String smtpHost = ( String ) myEnv.lookup ( "smtpHost" ) ;
Properties props = new Properties ( ) ;
props.put ( "mail.smtp.host", smtpHost ) ;
// Get a mail session. You would normally get this from
// JNDI, but some servers have a problem with this.
// Each Message Driven bean instance is responsible for
//getting its own unshared javax.mail.Session.
mailSession = javax.mail.Session.getDefaultInstance ( props, null ) ;
javax.mail.Message msg = new MimeMessage ( mailSession ) ;
// Set the mail properties
msg.setFrom ( new javax.mail.internet.InternetAddress ( "FromSomeone@KickJava.com" ) ;
InternetAddress [ ] addresses = {
new InternetAddress ( "ToSomeone@Kickjava.com" )
} ;
msg.setRecipients ( javax.mail.Message.RecipientType.TO, addresses ) ;
msg.setSubject ( "Subject" ) ;
msg.setSentDate ( new Date ( ) ) ;
// Create the body text
Multipart parts = new MimeMultipart ( ) ;
MimeBodyPart mainBody = new MimeBodyPart ( ) ;
mainBody.setText ( "Hello Body" ) ;
parts.addBodyPart ( mainBody ) ;
MimeBodyPart attachmentBody = new MimeBodyPart ( ) ;
attachmentBody.setText ( "This is text in the attachment" ) ;
attachmentBody.addBodyPart ( p2 ) ;
// Set some header fields
msg.setHeader ( "X-Priority", "High" ) ;
msg.setHeader ( "Sensitivity", "Company-Confidential" ) ;
msg.setContent ( parts ) ;
System.out.println ( "Sending mail to support@KickJava.com" ) ;
Transport.send ( msg ) ;
}
catch ( Exception ex ) {
ex.printStackTrace ( ) ;
}
finally {
mailSession = null;
}
//addFrom
public void addRecipient(Message.RecipientType type,
Address address)
throws MessagingException
- See Also:
- IllegalWriteException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public abstract void addRecipients(Message.RecipientType type,
Address[] addresses)
throws MessagingException
- See Also:
- IllegalStateException, IllegalWriteException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected boolean expunged
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected Folder folder
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public Address[] getAllRecipients()
throws MessagingException
- See Also:
getRecipients(javax.mail.Message.RecipientType)
, Message.RecipientType.BCC
, Message.RecipientType.CC
, Message.RecipientType.TO
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public abstract Flags getFlags()
throws MessagingException
- See Also:
setFlags(javax.mail.Flags, boolean)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public Folder getFolder()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public abstract Address[] getFrom()
throws MessagingException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public int getMessageNumber()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public abstract Date getReceivedDate()
throws MessagingException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public abstract Address[] getRecipients(Message.RecipientType type)
throws MessagingException
- See Also:
Message.RecipientType.BCC
, Message.RecipientType.CC
, Message.RecipientType.TO
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public Address[] getReplyTo()
throws MessagingException
- See Also:
getFrom()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public abstract Date getSentDate()
throws MessagingException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public abstract String getSubject()
throws MessagingException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public boolean isExpunged()
- See Also:
Folder.expunge()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public boolean isSet(Flags.Flag flag)
throws MessagingException
- See Also:
Flags.Flag.SEEN
, Flags.Flag.RECENT
, Flags.Flag.FLAGGED
, Flags.Flag.DRAFT
, Flags.Flag.DELETED
, Flags.Flag.ANSWERED
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public boolean match(SearchTerm term)
throws MessagingException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected Message()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected Message(Folder folder,
int msgnum)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected Message(Session session)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected int msgnum
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public abstract Message reply(boolean replyToAll)
throws MessagingException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public abstract void saveChanges()
throws MessagingException
- See Also:
- IllegalWriteException, IllegalStateException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected Session session
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected void setExpunged(boolean expunged)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setFlag(Flags.Flag flag,
boolean set)
throws MessagingException
- See Also:
MessageChangedEvent
, IllegalStateException, IllegalWriteException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public abstract void setFlags(Flags flag,
boolean set)
throws MessagingException
- See Also:
MessageChangedEvent
, IllegalStateException, IllegalWriteException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public abstract void setFrom()
throws MessagingException
- See Also:
- IllegalStateException, IllegalWriteException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public abstract void setFrom(Address address)
throws MessagingException
- See Also:
- IllegalStateException, IllegalWriteException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected void setMessageNumber(int msgnum)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setRecipient(Message.RecipientType type,
Address address)
throws MessagingException
- See Also:
- IllegalWriteException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public abstract void setRecipients(Message.RecipientType type,
Address[] addresses)
throws MessagingException
- See Also:
- IllegalStateException, IllegalWriteException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setReplyTo(Address[] addresses)
throws MessagingException
- See Also:
- MethodNotSupportedException, IllegalStateException, IllegalWriteException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public abstract void setSentDate(Date date)
throws MessagingException
- See Also:
- IllegalStateException, IllegalWriteException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public abstract void setSubject(String subject)
throws MessagingException
- See Also:
- IllegalStateException, IllegalWriteException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples