Adding Voting Button in mail [message #1225598] |
Mon, 30 December 2013 03:48 |
Eclipse User |
|
|
|
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();
}
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.04996 seconds