send mail with attachments
I downloaded a code from-
http://www.stardeveloper.com/articles/display.html?article=2001101101&page=1
it has four files: three files are ok. but there is one bean file.
--
MailerBean.class
--
package com.stardeveloper.bean.test;
import java.io.*;
import java.util.*;
import javax.mail.*;
import javax.mail.event.*;
import javax.mail.internet.*;
publicfinalclass MailerBeanextends Objectimplements Serializable{
/* Bean Properties */
private String to =null;
private String from =null;
private String subject =null;
private String message =null;
publicstatic Properties props =null;
publicstatic Session session =null;
static{
/*Setting Properties for STMP host */
props = System.getProperties();
props.put("mail.smtp.host","mail.yourisp.com");
session = Session.getDefaultInstance(props,null);
}
/* Setter Methods */
publicvoid setTo(String to){
this.to = to;
}
publicvoid setFrom(String from){
this.from = from;
}
publicvoid setSubject(String subject){
this.subject = subject;
}
publicvoid setMessage(String message){
this.message = message;
}
/* Sends Email */
publicvoid sendMail()throws Exception{
if(!this.everythingIsSet())
thrownew Exception("Could not send email.");
try{
MimeMessage message =new MimeMessage(session);
message.setRecipient(Message.RecipientType.TO,
new InternetAddress(this.to));
message.setFrom(new InternetAddress(this.from));
message.setSubject(this.subject);
message.setText(this.message);
Transport.send(message);
}catch (MessagingException e){
thrownew Exception(e.getMessage());
}
}
/* Checks whether all properties have been set or not */
privateboolean everythingIsSet(){
if((this.to ==null) || (this.from ==null) ||
(this.subject ==null) || (this.message ==null))
returnfalse;
if((this.to.indexOf("@") == -1) ||
(this.to.indexOf(".") == -1))
returnfalse;
if((this.from.indexOf("@") == -1) ||
(this.from.indexOf(".") == -1))
returnfalse;
returntrue;
}
}
1. Do i have to give some protocol names.
2. If so how do i find them.
3. I want to send mail from our intranet.(company).
4. I am using NetBeans 5.0. it is asked to save the bean file in a folder in web-inf\classes. but i dont have classses in that folder. Also i dont have libraries folder. Do I have to change any settings?
5. How can i create class for this bean file. If i save it in web-inf, it says u can not save it there and saves it in source packages. What shall i do.

