Results 1 to 4 of 4
  1. #1
    divya.dharan is offline Member
    Join Date
    Dec 2013
    Posts
    2
    Rep Power
    0

    Unhappy I wants to add voting button accept/reject in mail through java code

    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","pass wrd");}});
    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();
    }

    }
    }

  2. #2
    divya.dharan is offline Member
    Join Date
    Dec 2013
    Posts
    2
    Rep Power
    0

    Default I wants to add voting button accept/reject in mail through java code

    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","pass wrd");}});
    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();
    }

    }
    }

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,596
    Rep Power
    5

    Default Re: I wants to add voting button accept/reject in mail through java code

    IMO if an API or framework is poorly documented - don't use it.

    I would rather check out the extensive JavaMail FAQ to see if whatever you want to do is not covered in there:

    JavaMail API - FAQ
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,596
    Rep Power
    5

    Default Re: I wants to add voting button accept/reject in mail through java code

    One copy of the question is more than enough; this has nothing to do with Eclipse anyway.

    I wants to add voting button accept/reject in mail through java code
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. trying to sendin mail with java mail api
    By akhilsrivastava in forum Advanced Java
    Replies: 1
    Last Post: 04-04-2012, 09:34 PM
  2. BankAccount, how to reject negative amounts? PLEASE HELP!
    By armedrabbit in forum New To Java
    Replies: 6
    Last Post: 03-07-2011, 03:12 AM
  3. Replies: 2
    Last Post: 06-04-2009, 01:42 PM
  4. Why doesn't this code accept my code?
    By PeterFeng in forum New To Java
    Replies: 5
    Last Post: 02-03-2009, 01:39 PM
  5. Replies: 2
    Last Post: 05-05-2008, 06:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •