hi forum
i have new in java mail so i have already downloaded the javamail api in c drive and already unzip also in c drive so the problem is i want to set classpath of mail.jar file but where it is i can't able to find in the api please suggest me whole process to run simple java mail program
thanks
to run any java mail program i have already set following classpath
.;C:\Apps\Java\javamail-1.2\mail.jar;C:\Apps\Java
\javamail-1.2\mailapi.jar;C:\Apps\Java\javamail-1.2
\pop3.jar;C:\Apps\Java\javamail-1.2\smtp.jar;C:\Apps
\Java\jaf-1.1\activation.jar
now whenever i am going to compile any programme its showing error
package javax.activation.*; does not exist but i have already downloaded the activation.jar file and put above folder directory please tell me whats the solution for this
hi forum i have problem in java mail actually i compiled this code and the problem i have how to run this code please help me if anyone knows about that
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import java.util.*;
public class MailSender {
public void postMail(String smtpsrv, String recipients[], String subject,
String message, String from) throws MessagingException {
boolean debug = false;
//Set the host smtp address
Properties props = new Properties();
props.put("mail.smtp.host", smtpsrv);
// create some properties and get the default Session
Session session = Session.getDefaultInstance(props, null);
session.setDebug(debug);
// create a message
Message msg = new MimeMessage(session);
// set the from and to address
InternetAddress addressFrom = new InternetAddress(from);
msg.setFrom(addressFrom);
InternetAddress addressTo[]= new InternetAddress[recipients.length];
addressTo= new InternetAddress[recipients.length];
for (int i = 0; i < recipients.length; i++)
{
addressTo= new InternetAddress(recipients);
}
msg.setRecipients(Message.RecipientType.TO,addressTo);
// Setting the Subject and Content Type
msg.setSubject(subject);
msg.setContent(message, "text/html;charset=utf-8");
Transport.send(msg);
}
}