dcsimg
while programming a javamail system i'm getting an exception.I'm working on Windows'98 and the cable internet connection that i have.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   lakshman_kumar
Posted On:   Tuesday, October 9, 2001 02:52 AM

This is my Program to be done successfully.......... import java.util.Properties; import javax.mail.*; import javax.mail.internet.*; public class MailExample { public static void main (String args[]) throws Exception { String host = args[0]; String from = args[1]; String to = args[2]; // Get system properties Properties props = System.getProperties(); // Setup mail server props.put("mail.smtp.host", host); // Get session Session session = Session.getDefaultInstance(props, null); // Define message MimeMessage message = new MimeMessage(session);    More>>

This is my Program to be done successfully..........

import java.util.Properties;

import javax.mail.*;

import javax.mail.internet.*;

public class MailExample {

public static void main (String args[]) throws Exception {

String host = args[0];

String from = args[1];

String to = args[2];

// Get system properties

Properties props = System.getProperties();

// Setup mail server

props.put("mail.smtp.host", host);

// Get session

Session session = Session.getDefaultInstance(props, null);

// Define message

MimeMessage message = new MimeMessage(session);

// Set the from address

message.setFrom(new InternetAddress(from));

// Set the to address

message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));

// Set the subject

message.setSubject("Hello JavaMail");

// Set the content

message.setText("Welcome to JavaMail");

// Send message

Transport.send(message);


}

}

After compiling the code,

This is my error.


D:lakshmanNew Folder>java MailExample -o vijaygopal_sana@yahoo.com -M SMTP.Ser
ver lakshman_y@rediffmail.com




Exception in thread "main"
javax.mail.SendFailedException: Sending failed;

nested exception is:
javax.mail.MessagingException: Unknown SMTP host: -o;

nested exception is:
java.net.UnknownHostException: -o
at javax.mail.Transport.send0(Transport.java:219)

at javax.mail.Transport.send(Transport.java:81)

at MailExample.main(MailExample.java:27)

   <<Less

Re: while programming a javamail system i'm getting an exception.I'm working on Windows'98 and the cable internet connection that i have.

Posted By:   John_Zukowski  
Posted On:   Wednesday, October 10, 2001 09:49 AM

Read the exception. It tells you exactly what the problem is. Look at what the program requires for arguments.
About | Sitemap | Contact