import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
void email()
{
Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);
String msgBody = name + "\n" + description + "\n" + email;
try {
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("sender@email.com",
"sender"));
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(
"recipientEmail", "recipientName"));
msg.setSubject("Greetings");
msg.setText("Hello");
Transport.send(msg);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
No comments:
Post a Comment