sending mail problems
Hi
I have this program that it works independetly but when I create an object from it from another program, it doesn't go through after the creation of the session.It stops atMessage msg = new MimeMessage(session); can some one help me and tell me the problem .thanks
import java.io.PrintWriter;
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
public class Test3 {
public void send(String to,String from,String message){
String cc = "";
String bcc = "";
String host = "smtp-gw.fr.world.socgen";
Properties props = new Properties();
props.put("mail.smtp.host", host);
props.put("mail.debug", "true");
try {
Session session = Session.getInstance(props);
// Here is the problem when it doesn't go throught
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO,address);
if(cc !=null)
{msg.setRecipients(Message.RecipientType.CC,
InternetAddress.parse(cc,true));}
if(bcc !=null)
{msg.setRecipients(Message.RecipientType.BCC,
InternetAddress.parse(bcc,true));}
msg.setSubject("Error Message");
msg.setSentDate(new Date());
msg.setContent(message, "text/plain");
Transport.send(msg);
System.out.println("yes");
}
catch (MessagingException ex){
System.err.println("Cannot send the email. " + ex);
}
}
}

