Discussions
Categories
Choose a Product
THRUST SERVICES
CORE APPS
CE PRODUCTS
...
Quick Links
POPULAR
HELPFUL TIPS
Groups
My Links
FOR SIGNED IN MEMBERS:
Back to website
Home
Designing Analytics Reports
call a class from birt
Migrateduser
Hi friends ,
I am not very much aware of java thing inside birt .Below is the java code which i need to call from inside birt report .
Also this java code needs parameter which is to be sent by birt report like Email id .
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
class SendAttachment{
public void sendMail(String to)// throws MessagingException, AddressException
{
final String user="abc@123.com";
final String password="123456";
Properties properties = System.getProperties();
properties.setProperty("mail.smtp.host", "smtp.abc.com");
properties.put("mail.smtp.auth", "true");
properties.put("mail.smtp.ssl.enable", "true");
Session session = Session.getDefaultInstance(properties,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(user,password);
}
});
try{
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(user));
message.addRecipient(Message.RecipientType.TO,new InternetAddress(to));
message.setSubject("Message Aleart");
BodyPart messageBodyPart1 = new MimeBodyPart();
messageBodyPart1.setText("success");
MimeBodyPart messageBodyPart2 = new MimeBodyPart();
String filename = "SendAttachment.java";
DataSource source = new FileDataSource(filename);
messageBodyPart2.setDataHandler(new DataHandler(source));
messageBodyPart2.setFileName(filename);
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart1);
multipart.addBodyPart(messageBodyPart2);
message.setContent(multipart );
Transport.send(message);
System.out.println("message sent....");
}catch (MessagingException ex) {ex.printStackTrace();}
}
public static void main(String [] args){
SendAttachment client = new SendAttachment();
String to="123@abc.com";
client.sendMail(to);
}
}
regards
Vineet
Find more posts tagged with
Comments
There are no comments yet