• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Anybody here know any Java?

AMDPwred

Diamond Member
I'm looking for a little help on a SendMail program. If you guys can figure out what I'm doing wrong, please let me know. I'm having a heck of a time trying to figure this out.

<code>

package email;

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

public class Sender {

protected String message_recip = "AMDPwred@mediaone.net";
protected String message_subject = "Test Email";
protected String message_cc = "";
protected String message_body = "This is just a test. ";

/* JavaMail session object */
protected Session session;
/* JavaMail message object */
protected Message mesg;

public void doSend() {

Properties props = new Properties();
props.put("VA.SMTP.mediaone.net", "mailhost");

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

try {
mesg = new MimeMessage(session);
mesg.setFrom(new InternetAddress("My Email"));

InternetAddress toAddress = new InternetAddress(message_recip);
mesg.addRecipient(Message.RecipientType.TO, toAddress);

InternetAddress ccAddress = new InternetAddress(message_cc);
mesg.addRecipient(Message.RecipientType.CC, ccAddress);

mesg.setSubject(message_subject);

mesg.setText(message_body);

Transport.send(mesg);

} catch (MessagingException ex) {
while ((ex = (MessagingException)ex.getNextException()) != null) {
ex.printStackTrace();
}
}
}

public static void main(String[] av) {
int cnt = 1;
for (int i = 0; i < cnt; i++) {
Sender sm = new Sender();
sm.doSend();
}
}
}

</code>

And I get these as my errors:

C:\Program Files\JBuilder5\jdk1.3\bin\javaw -classpath "C:\Documents and Settings\Chris Stewart\jbproject\EMail\classes\email;C:\javamail-1.2\imap.jar;C:\javamail-1.2\mail.jar;C:\javamail-1.2\mailapi.jar;C:\javamail-1.2\pop3.jar;C:\javamail-1.2\smtp.jar;C:\Program Files\JBuilder5\jdk1.3\demo\jfc\Java2D\Java2Demo.jar;C:\Program Files\JBuilder5\jdk1.3\jre\lib\i18n.jar;C:\Program Files\JBuilder5\jdk1.3\jre\lib\jaws.jar;C:\Program Files\JBuilder5\jdk1.3\jre\lib\rt.jar;C:\Program Files\JBuilder5\jdk1.3\jre\lib\sunrsasign.jar;C:\Program Files\JBuilder5\jdk1.3\lib\dt.jar;C:\Program Files\JBuilder5\jdk1.3\lib\tools.jar" email.Sender


java.lang.NoClassDefFoundError: javax/activation/DataSource
at email.Sender.doSend(Sender.java:38)
at email.Sender.main(Sender.java:64)
Exception in thread "main"

Any ideas?
 
I did and it gave:

"Sender.java": Error #: 901 : package . stated in source c:\Documents and Settings\Chris Stewart\jbproject\EMail\src\email\Sender.java does not match directory email

BTW, I'm using JBuilder 5.
 
I believe you need a activation package for your java mail to work. I this this can be found in the java.sun.com web site. Get the jar file, place it in your classpath and try again. Hopefully that should work.
 
I downloaded the newest version of JavaMail (Dec 2000 I think it was) and added all of the jar files to my classpath.
 


<< I believe you need a activation package for your java mail to work. I this this can be found in the java.sun.com web site. Get the jar file, place it in your classpath and try again. Hopefully that should work. >>



Oh ok, I see what you mean. Let me try that quick.
 
Good catch bud, that did the trick. I'm not getting the email though but that's a problem with my SMTP settings and all I think. Thanks for your help!
 
I'm having some trouble sending out the email now. Do you guys know if my SMTP is correct (the structure of it)? I know the VA.mediaone.net part is, because it's mine😉
 
Back
Top