Java mail outlook appointment issue

Discussion in 'Java' started by Pedro Pinto, Nov 20, 2007.

  1. Pedro Pinto

    Pedro Pinto Guest

    Hi there to everyone!

    I've been reseaching this topic. So far, the best efford for the
    operation is:

    Can send an e-mail with an outlook meeting request,
    User receives e-mail with an attachment file, meeting.ics,
    User can open and accept meeting and organizer receives read report
    and acceptance,
    User and Organizer cannot see the attendees of the meeting.

    The issue, has described, is that the invitation is sent well but when
    openning with Microsoft Outlook only the meeting organizer appears!
    Does anyone knows how to solve this issue?

    Thanks in advance.

    Bellow goes the code.

    -------------------------------

    public class Mail {

    /** Creates a new instance of Mail */
    public Mail() {
    }


    public static void main(String[] args){

    try{


    MimetypesFileTypeMap mimetypes =
    (MimetypesFileTypeMap)MimetypesFileTypeMap.getDefaultFileTypeMap();
    mimetypes.addMimeTypes("text/calendar ics ICS");

    MailcapCommandMap mailcap =
    (MailcapCommandMap)MailcapCommandMap.getDefaultCommandMap();
    mailcap.addMailcap("text/calendar;; x-java-content-
    handler=com.sun.mail.handlers.text_plain");

    //Calendar calendar = builder.build(fin);

    String host = "xxx"; //Outbound mail address
    String from = "";
    String to = "";

    // Get system properties
    Properties props = System.getProperties();

    // Setup mail server
    props.put("mail.smtp.host", host);

    // Get session
    Session session = Session.getInstance(props, null);

    // Define message
    MimeMessage message = new MimeMessage(session);
    message.addHeaderLine("method=REQUEST");
    message.addHeaderLine("charset=UTF-8");
    message.addHeaderLine("component=vevent");

    message.setFrom(new InternetAddress(from));
    //message.addRecipient(Message.RecipientType.TO, new
    InternetAddress(to));
    message.addRecipient(Message.RecipientType.TO, new
    InternetAddress(from));
    message.addRecipient(Message.RecipientType.TO, new
    InternetAddress(""));
    message.setSubject("Outlook Meeting Request Using
    JavaMail");

    StringBuffer sb = new StringBuffer();


    StringBuffer buffer = sb.append("BEGIN:VCALENDAR\n" +
    "PRODID:-//Microsoft Corporation//Outlook 11.0
    MIMEDIR//EN\n" +
    "VERSION:2.0\n" +
    "METHOD:REQUEST\n" +
    "BEGIN:VEVENT\n" +
    "ATTENDEE;CN=\"xxx\";ROLE=REQ-
    PARTICIPANT;RSVP=TRUE:MAILTO:\n"+
    "ATTENDEE;CN=\"xxx\";ROLE=REQ-
    PARTICIPANT;RSVP=TRUE:MAILTO:\n"+
    "ORGANIZER:MAILTO:\n" +
    "DTSTART:20071120T193000Z\n" +
    "DTEND:20071120T200000Z\n" +
    "LOCATION:Conference room\n" +
    "TRANSP:OPAQUE\n" +
    "SEQUENCE:0\n" +
    "UID:
    040000008200E00074C5B7101A82E00800000000002FF467CE3AC5010000000000000000100\n"
    +
    " 000004377FE5C37984842BF9440448399EB02\n" +
    "DTSTAMP:20071120T120102Z\n" +
    "DESCRIPTION:This the description of the meeting.
    \n" +
    "SUMMARY:Test meeting request\n" +
    "PRIORITY:5\n" +
    "X-MICROSOFT-CDO-IMPORTANCE:1\n"+
    "CLASS:pUBLIC\n" +
    "BEGIN:VALARM\n" +
    "TRIGGER:pT15M\n" +
    "ACTION:DISPLAY\n" +
    "DESCRIPTION:Reminder\n" +
    "END:VALARM\n" +
    "END:VEVENT\n" +
    "END:VCALENDAR");

    // Create the message part
    BodyPart messageBodyPart = new MimeBodyPart();
    System.out.println(sb);
    // Fill the message
    messageBodyPart.setText("You are requested to participlate
    in the review meeting.");

    // Create a Multipart
    Multipart multipart = new MimeMultipart();

    // Add part one
    multipart.addBodyPart(messageBodyPart);

    // Part two is attachment
    // Create second body part
    messageBodyPart = new MimeBodyPart();
    String filename = "invitation.ics";
    messageBodyPart.setFileName(filename);
    messageBodyPart.setHeader("Content-Class", "urn:content-
    classes:calendarmessage");
    messageBodyPart.setHeader("Content-
    ID","calendar_message");
    messageBodyPart.setContent(buffer.toString(), "text/
    calendar");

    // Add part two
    multipart.addBodyPart(messageBodyPart);

    // Put parts in message
    message.setContent(multipart);

    // send message
    Transport.send(message);
    } catch (MessagingException me) {
    me.printStackTrace();
    } catch (Exception ex) {
    ex.printStackTrace();
    }




    }

    }
    Pedro Pinto, Nov 20, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?R2Vvcmdlcw==?=

    Create outlook appointment - web form

    =?Utf-8?B?R2Vvcmdlcw==?=, Aug 4, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    1,237
    =?Utf-8?B?R2Vvcmdlcw==?=
    Aug 4, 2004
  2. chuckdfoster

    Create an Outlook Appointment

    chuckdfoster, Dec 21, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    9,418
    chuckdfoster
    Dec 22, 2004
  3. Matt Moran
    Replies:
    0
    Views:
    124
    Matt Moran
    Jul 10, 2003
  4. Akira
    Replies:
    0
    Views:
    257
    Akira
    Feb 21, 2005
  5. Sean Nakasone
    Replies:
    1
    Views:
    189
    David Mullet
    Feb 15, 2008
Loading...

Share This Page