There doesn't seem to be any problem with your code.It ran fine.
Have a nice day.
With regards,
Sachin S. Khanna
http://www.emailanorder.com
----- Original Message -----
From: Raghu Movva <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, April 18, 2001 2:37 PM
Subject: problem with javamail


> Hi,
>   I have written a program using javamail.  It is compiling correctly.
But
> when I am running the code it is giving the following error.  Can any body
> please figure it out.  The error is "java.lang.Noclassdeffounderror
> com/sun/mail/utilMailDateFormat.
> I am sending the code also
>
>
> import javax.mail.*;
> import javax.mail.internet.*;
> import java.util.*;
>
> public class SendEmail
> {
>  public static void main(String[] args)
>  {
>   if (args.length != 6)
>   {
>    System.out.println("usage: sendmessage <to> <from> <smtphost>
> <true|false> <subject> <text>");
>    System.exit(1);
>   }
>   SendMessage(args[0],args[1], args[2], args[3], args[4], args[5]);
>  }
>
> public static String SendMessage(String emailto, String emailfrom, String
> smtphost, String emailmultipart, String msgSubject, String msgText)
>   {
>     boolean debug = false; // change to get more information
>     String msgText2 = "multipart message";
>     boolean sendmultipart =
Boolean.valueOf(emailmultipart).booleanValue();
>     // set the host
>     Properties props = new Properties();
>     props.put("mail.smtp.host", smtphost);
>     // create some properties and get the default Session
>     Session session = Session.getInstance(props, null);
>     session.setDebug(debug);
>     try
>     {
>       // create a message
>       Message msg = new MimeMessage(session);
>       // set the from
>       InternetAddress from = new InternetAddress(emailfrom);
>       msg.setFrom(from);
>       InternetAddress[] address =
>       {
>         new InternetAddress(emailto)
>       };
>       msg.setRecipients(Message.RecipientType.TO, address);
>       msg.setSubject(msgSubject);
>       if(!sendmultipart)
>       {
>         // send a plain text message
>         msg.setContent(msgText, "text/plain");
>       }
>       else
>       {
>         // send a multipart message// create and fill the first message
part
>         MimeBodyPart mbp1 = new MimeBodyPart();
>         mbp1.setContent(msgText, "text/plain");
>         // create and fill the second message part
>         MimeBodyPart mbp2 = new MimeBodyPart();
>         mbp2.setContent(msgText2, "text/plain");
>         // create the Multipart and its parts to it
>         Multipart mp = new MimeMultipart();
>         mp.addBodyPart(mbp1);
>         mp.addBodyPart(mbp2);
>         // add the Multipart to the message
>         msg.setContent(mp);
>       }
>       Transport.send(msg);
>     }
>     catch(Exception e)
>     { System.out.println(e);
>       e.printStackTrace();
>     }
>     return "Email sent to " + emailto;
>   }
>
> }
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to