Java Reference
In-Depth Information
/** Send the message.
*/
public
public synchronized
synchronized void
void doSend () throws
throws MessagingException {
iif (! isComplete ())
throw
throw new
new IllegalArgumentException (
"doSend called before message was complete" );
/** Properties object used to pass props into the MAIL API */
Properties props = new
new Properties ();
props . put ( "mail.smtp.host" , mailHost );
// Create the Session object
iif ( session == null
null ) {
session = Session . getDefaultInstance ( props , null
null );
iif ( verbose )
session . setDebug ( true
true );
// Verbose!
}
// create a message
final
final Message mesg = new
new MimeMessage ( session );
InternetAddress [] addresses ;
// TO Address list
addresses = new
new InternetAddress [ toList . size ()];
for
for ( int
int i = 0 ; i < addresses . length ; i ++)
addresses [ i ] = new
new InternetAddress (( String ) toList . get ( i ));
mesg . setRecipients ( Message . RecipientType . TO , addresses );
// From Address
mesg . setFrom ( new
new InternetAddress ( from ));
// CC Address list
addresses = new
new InternetAddress [ ccList . size ()];
for
for ( int
int i = 0 ; i < addresses . length ; i ++)
addresses [ i ] = new
new InternetAddress (( String ) ccList . get ( i ));
mesg . setRecipients ( Message . RecipientType . CC , addresses );
// BCC Address list
addresses = new
new InternetAddress [ bccList . size ()];
for
for ( int
int i = 0 ; i < addresses . length ; i ++)
addresses [ i ] = new
new InternetAddress (( String ) bccList . get ( i ));
mesg . setRecipients ( Message . RecipientType . BCC , addresses );
Search WWH ::




Custom Search