| Author |
sending mail with JavaMail and Exchange Server
|
Ruud Steeghs
Ranch Hand
Joined: Jul 09, 2001
Posts: 56
|
|
Hi, At work I have to send an email using Microsoft Exchange Server. I have succeeded sending mail at home using smtp-protocol. However, this does not work in my projec. Does anyone have an idea on what property to set, for "mail.smtp.host" is not the right property? Below is the code that works for me at home. (taken from sun tutorial) Cheers, Ruud. import java.util.Properties; import javax.mail.*; import javax.mail.internet.*; public class SendMail { public static void main (String args[]) throws Exception { String host = "mail.notreal.com"; String from = "from-name@provider.com"; String to = "to-name@provider.com"; Properties props = System.getProperties(); props.put("mail.smtp.host", host); Session session = Session.getDefaultInstance(props,null); MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress(from)); message.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); System.out.println(" setting subject and message "); message.setSubject("hi "); message.setText("how r u"); Transport.send(message); System.out.println(" sent the message "); System.out.println(" thanks "); } }
|
 |
Ruud Steeghs
Ranch Hand
Joined: Jul 09, 2001
Posts: 56
|
|
Problem solved! Apparently, I was using the wrong smtp-host. I used the smtp-host that I found in my Outlook, but I had to use another one.
|
 |
 |
|
|
subject: sending mail with JavaMail and Exchange Server
|
|
|