Win a copy of Head First Android this week in the Android forum!

Krzysztof Kwiatek

Greenhorn
+ Follow
since Jan 14, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Krzysztof Kwiatek

} catch (MessagingException mex) {
mex.printStackTrace();
Exception ex = null;
if ((ex = mex.getNextException()) != null) {
ex.printStackTrace();
}

} catch (Exception e) {
}
17 years ago
hi you write too much code. To send email only you need to type
Transport.send(message);
my example:
Properties props = new Properties();

Authenticator auth = new MyAuthenticator();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.host", host);
Session session = Session.getDefaultInstance(props, auth);
session.setDebug(true);
try {
// create a message
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);

msg.setSubject(temat);
// create and fill the first message part
MimeBodyPart mbp1 = new MimeBodyPart();
mbp1.setText(cialo);

Multipart mp = new MimeMultipart();
mp.addBodyPart(mbp1);
//mp.addBodyPart(mbp2);
// add the Multipart to the message
msg.setContent(mp);
// set the Date: header
msg.setSentDate(new Date());

// send the message
Transport.send(msg);
17 years ago