Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Espanol
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Espanol section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 4th, 2005, 06:41 AM
Authorized User
 
Join Date: Sep 2004
Location: Delhi, Delhi, India.
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error

I m trying to send a mail using following code but getting error
"exception in thread "main" java.lang.noclassdef found error"

Pl help

import java.io.*;
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;

public class SendEVGMail {
  public static void main (String args[])
      throws Exception {
    String host = args[0];
    String from = args[1];
    String to = args[2];
    String fileAttachment = args[3];

    // Get system properties
    Properties props = System.getProperties();

    // Setup mail server
    props.put("mail.smtp.host", host);

    // Get session
    Session session =
      Session.getInstance(props, null);

    // Define message
    MimeMessage message =
      new MimeMessage(session);
    message.setFrom(
      new InternetAddress(from));
    message.addRecipient(
        Message.RecipientType.TO,
        new InternetAddress("sumits@lot.tatasteel.com"));

   /* message.addRecipient(
        Message.RecipientType.TO,
        new InternetAddress(""));

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


    message.addRecipient(
            Message.RecipientType.CC,
            new InternetAddress(""));




    message.addRecipient(
        Message.RecipientType.CC,
        new InternetAddress(""));*/

    message.setSubject(
      "Test from java File Attached.");

    // create the message part
    MimeBodyPart messageBodyPart =
      new MimeBodyPart();

    //fill message
    messageBodyPart.setText("Testing the mail programme from java,File Attached \n");

    Multipart multipart = new MimeMultipart();
    multipart.addBodyPart(messageBodyPart);

    // Part two is attachment
    messageBodyPart = new MimeBodyPart();
    DataSource source =
      new FileDataSource(fileAttachment);
    messageBodyPart.setDataHandler(
      new DataHandler(source));
    messageBodyPart.setFileName(fileAttachment);
    multipart.addBodyPart(messageBodyPart);

    // Put parts in message
    message.setContent(multipart);

    // Send the message
    Transport.send( message );
  }
}


It is always safe to assume, not that the old way is wrong, but that there may be a better way...
*************************
Rekha
__________________
It is always safe to assume, not that the old way is wrong, but that there may be a better way...
*************************
Rekha
Reply With Quote
  #2 (permalink)  
Old February 4th, 2005, 06:15 PM
Authorized User
 
Join Date: Feb 2005
Location: Chennai, Tamil Nadu, India.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rockyrak
Default

Hi,

How you named that file. tell me the file name.



Ram
Reply With Quote
  #3 (permalink)  
Old February 4th, 2005, 11:25 PM
Authorized User
 
Join Date: Sep 2004
Location: Delhi, Delhi, India.
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

file name is SendEVGMail


It is always safe to assume, not that the old way is wrong, but that there may be a better way...
*************************
Rekha
Reply With Quote
  #4 (permalink)  
Old February 7th, 2005, 04:08 PM
Authorized User
 
Join Date: Feb 2005
Location: Chennai, Tamil Nadu, India.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rockyrak
Default

Hi,

i think you are executing the file with the extension.

try like this,

java SendEVGMail

not with the extension. i don't think there is something else wrong in the program.



Ram
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Query Error & Run-Time Error 3022 DavidWE Access 1 July 31st, 2008 11:17 AM
Ch 4: Parse error: syntax error, unexpected T_SL hanizar77 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 June 23rd, 2008 09:17 PM
[Resolved] Error calling a sp - parameter error snufse .NET Framework 2.0 2 February 12th, 2008 03:46 PM
Parse error: syntax error, unexpected T_STRING ginost7 Beginning PHP 1 November 9th, 2007 01:51 AM
Phile Page error, visual studio error reps BOOK: ASP.NET Website Programming Problem-Design-Solution 0 September 27th, 2003 10:11 AM



All times are GMT -4. The time now is 07:31 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.