This might work for you - create a library with the
following code and get the JavaMail & Java Activation Framework libraries
from JavaSoft.
import javax.mail.*;
import javax.mail.internet.*; import java.util.*; import java.io.*; public class EmailManager
{ public static boolean sendEmail( String from, String to, String subject, String text, String smtpHost ) { boolean wasSent = true; Session theSession = null; InternetAddress theAddress[] = null; Properties p = new
Properties();
p.put( "mail.smtp.host", smtpHost ); theSession = Session.getDefaultInstance( p, null ); theAddress = new
InternetAddress[ 1 ];
try { theAddress[0] = new InternetAddress( to ); Message msg = new
MimeMessage( theSession );
msg.setFrom( new
InternetAddress( from ) );
msg.setSubject( subject ); msg.setContent( text, "text/plain" ); msg.setRecipients( Message.RecipientType.TO, theAddress ); Transport.send( msg
);
} catch ( Exception ex ) { ex.printStackTrace(); wasSent = false; } return wasSent;
} public static void main( String args[]
)
{ EmailManager.sendEmail( "[EMAIL PROTECTED]", "[EMAIL PROTECTED]", "Ergle!", "This is a test", "some.smtp.server" ); } }
|
- emails Aimn
- Re: emails Tom Santos
- Re: emails Richard Vowles
- Re: emails Phil Campbell
- Re: emails parthipan vajeravelu
