mialing code execution is stoped at transport.send(msg)

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Apr 2008
Posts: 2
Reputation: ravikiran.s is an unknown quantity at this point 
Solved Threads: 0
ravikiran.s ravikiran.s is offline Offline
Newbie Poster

mialing code execution is stoped at transport.send(msg)

 
0
  #1
Apr 29th, 2008
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
import javax.activation.*;
import java.io.*;
public class SimpleSender
{
public static void main(String args[])
{
try
{
String smtpServer=args[0];
String to=args[1];
String from=args[2];
String body=args[3];
send(smtpServer, to, from,body);
}
catch (Exception ex)
{
System.out.println("Usage :\njava SimpleSender server to from body");
}
System.exit(0);
}

public static void send(String smtpServer, String to, String from, String body)
{
try
{
Properties props = System.getProperties();
props.put("mail.smtp.host", smtpServer);
props.put("mail.smtp.port", "465");
Session session = Session.getDefaultInstance(props, null);
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to, false));
msg.setSubject("Test Mail thru java");
msg.setContent(body,"text/plain");
msg.setSentDate(new Date());
System.out.println("Message sent OK1.");

Transport.send(msg);

System.out.println("Message sent OK2.");
}
catch (Exception ex)
{
ex.printStackTrace();
}
}


}
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,515
Reputation: Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future 
Solved Threads: 523
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: mialing code execution is stoped at transport.send(msg)

 
0
  #2
Apr 29th, 2008
"execution is stopped" isn't a lot of information to go on. You have an exception? What is it exactly? The code just never returns from that method? You're going to need to give a little bit more detail on your issue if you expect anyone to offer some advice.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 2
Reputation: ravikiran.s is an unknown quantity at this point 
Solved Threads: 0
ravikiran.s ravikiran.s is offline Offline
Newbie Poster

Re: mialing code execution is stoped at transport.send(msg)

 
0
  #3
Apr 29th, 2008
at console the curser is waiting whene Transport.send(msg) was accured. so it is not printing the massege like "massege is sent".. it was found by tracing the code line by line by giving System.out.println().
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 727 | Replies: 2
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC