java.lang.Object
javax.mail.Service
javax.mail.Transport
- See Also:
- Top Examples, Source Code,
ConnectionEvent
,
TransportEvent
public void addTransportListener(TransportListener l)
- See Also:
TransportEvent
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected void notifyTransportListeners(int type,
Address[] validSent,
Address[] validUnsent,
Address[] invalid,
Message msg)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void removeTransportListener(TransportListener l)
- See Also:
addTransportListener(javax.mail.event.TransportListener)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static void send(Message msg)
throws MessagingException
- See Also:
SendFailedException
, send(Message, Address[])
, Message.getAllRecipients()
, Message.saveChanges()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[226]Create a text mail attachment
By Anonymous on 2005/09/02 16:23:54 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;
}
[1991]Create the pool of Transport objects
By Maruthi Sayampu on 2009/03/26 22:07:18 Rate
// it gets one Transport object from the mailSession
Transport tranportObject = mailSession.getTransport ( ) ;
// We need to create the pool of transport objects and get
public OwnTransport extends Transport implements someInterface
{
it will internally calls the pool class to maintain the pool
}
public static void send(Message msg,
Address[] addresses)
throws MessagingException
- See Also:
SendFailedException
, send(Message)
, Message.saveChanges()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public abstract void sendMessage(Message msg,
Address[] addresses)
throws MessagingException
- See Also:
TransportEvent
, SendFailedException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public Transport(Session session,
URLName urlname)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples