Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Adding Voting Button in mail(I wants to add voting button accept/reject in mail through java code)
icon8.gif  Adding Voting Button in mail [message #1225598] Mon, 30 December 2013 03:48
Eclipse UserFriend
Hi All,

In my project I wants to send a mail with attachment and voting button.
I could able to send mail with attahment as shown below.
But I dnt know how to add voting button.
I've researched that there is a library: JTNEF , but its hard to find document how to use it.

Anyone from you(community) already used this library?
Please really would appreciate if you could show me how send email in JTNEF that have Voting Buttons in Microsoft Exchange.

// File Name SendFileEmail.java

import java.util.Properties;

import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import javax.mail.Message;
import javax.mail.Multipart;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;

import net.freeutils.tnef.TNEFInputStream;

public class SendFileEmail
{
public static void main(String [] args)
{
String SMTP_HOST_NAME = "xxx";
String SMTP_PORT = "25";
TNEFInputStream in = null;

String SMTP_FROM_ADDRESS="aa";
String SMTP_TO_ADDRESS="yy";
String subject="Textmsg";
String fileAttachment = "E:\\file.txt";

Properties props = new Properties();

props.put("mail.smtp.host", SMTP_HOST_NAME);
props.put("mail.smtp.auth", "true");
props.put("mail.debug", "true");
props.put("mail.smtp.port", SMTP_PORT );
Session session = Session.getInstance(props,new javax.mail.Authenticator()
{protected javax.mail.PasswordAuthentication
getPasswordAuthentication()
{return new javax.mail.PasswordAuthentication("username","passwrd");}});
try{

Message msg = new MimeMessage(session);

msg.setFrom(new InternetAddress(SMTP_FROM_ADDRESS));
// create the message part
MimeBodyPart messageBodyPart =
new MimeBodyPart();
//fill message
messageBodyPart.setText("Test mail one");
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
msg.setContent(multipart);


msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(SMTP_TO_ADDRESS));

msg.setSubject(subject);
// msg.setContent(content, "text/plain");

Transport.send(msg);
System.out.println("success....................................");
}
catch(Exception e){
e.printStackTrace();
}

}
}
Previous Topic:Code Templates Not Working
Next Topic:Eclipse Keplar and Ant 1.8.2
Goto Forum:
  


Current Time: Tue Apr 22 13:17:33 EDT 2025

Powered by FUDForum. Page generated in 0.04996 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top