Sending MS Outlook Meeting Request

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vidi
    New Member
    • Sep 2006
    • 4

    Sending MS Outlook Meeting Request

    Hi all,

    Can someone please send me a working JAVA code that would send a Meeting Request to MS Outlook ?

    I Badly need this ASAP ...

    My id: mailvidi@gmail. com

    Thank You,
    Vidi
  • vidi
    New Member
    • Sep 2006
    • 4

    #2
    Originally posted by vidi
    Hi all,

    Can someone please send me a working JAVA code that would send a Meeting Request to MS Outlook ?

    I Badly need this ASAP ...

    My id: mailvidi@gmail. com

    Thank You,
    Vidi

    Hi People ... finally my friend & i have found the solution ourselves !!! If you want the code, lemme know ...
    K.R.Vidya Shankar

    Comment

    • andys1316
      New Member
      • Jan 2007
      • 1

      #3
      Originally posted by vidi
      Hi People ... finally my friend & i have found the solution ourselves !!! If you want the code, lemme know ...
      K.R.Vidya Shankar

      Can you please post the code? I've been looking for this solution for sometime. Thanks!

      Comment

      • mailvidi
        New Member
        • Sep 2006
        • 1

        #4
        Ok People, here's it.. Lemme know if that works..

        public void send(String uniqueId, Date reviewDateTime) throws Exception
        {
        String from = "123@456.co m";
        String to = "456@456.co m";
        String meetingStartTim e = getReviewTime(r eviewDateTime, false);
        String meetingEndTime = getReviewTime(r eviewDateTime, true);
        Properties prop = new Properties();
        StringBuffer sb = new StringBuffer();
        StringBuffer buffer = null;
        Session session = Session.getDefa ultInstance(pro p, null);
        Message message = new MimeMessage(ses sion);

        try {
        prop.put("mail. smtp.host", "192.168.112.11 1");
        prop.put("mail. smtp.port", "25");

        // Define message
        message.setFrom (new InternetAddress (from));
        message.setReci pients(Message. RecipientType.T O, InternetAddress .parse(to, false));
        message.setReci pients(Message. RecipientType.C C, InternetAddress .parse("123@456 .com,456@456.co m,789@456.com") );
        message.setSubj ect("This is the subject of the Meeting Request");
        message.setHead er("X-Mailer", "iQuest-Mailer");

        // Create the message part
        MimeBodyPart messageBodyPart = new MimeBodyPart();
        buffer = sb.append("BEGI N:VCALENDAR\n"
        + "PRODID:-//Microsoft Corporation//Outlook9.0 MIMEDIR//EN\n"
        + "VERSION:2. 0\n"
        + "METHOD:REQUEST \n"
        + "BEGIN:VEVENT\n "
        + "ATTENDEE;ROLE= REQ-PARTICIPANT;RSV P=TRUE:MAILTO:1 23@456.com\n"
        + "ORGANIZER:MAIL TO:456@456.com\ n"
        + "DTSTART:" + meetingStartTim e + "\n"
        + "DTEND:" + meetingEndTime + "\n"
        + "LOCATION:Confe rence room\n"
        + "TRANSP:OPAQUE\ n"
        + "SEQUENCE:0 \n"
        + "UID:" + uniqueId + "@456.com\n "
        + "DTSTAMP:" + meetingEndTime + "\n"
        + "CATEGORIES:Mee ting\n"
        + "DESCRIPTION:Th is the description of the meeting.\n\n"
        + "SUMMARY:Te st meeting request\n" + "PRIORITY:1 \n"
        + "CLASS:PUBLIC\n " + "BEGIN:VALARM\n "
        + "TRIGGER:PT1440 M\n" + "ACTION:DISPLAY \n"
        + "DESCRIPTION:Re minder\n" + "END:VALARM \n"
        + "END:VEVENT \n" + "END:VCALENDAR" );
        messageBodyPart .setFileName("m eeting.ics");
        messageBodyPart .setDataHandler (new DataHandler(new ByteArrayDataSo urce(buffer.toS tring(), "text/iCalendar")));
        messageBodyPart .setHeader("Con tent-Class","urn:con tent-classes:calenda rmessage");
        messageBodyPart .setHeader("Con tent-ID", "calendar_messa ge");
        Multipart multipart = new MimeMultipart() ;
        multipart.addBo dyPart(messageB odyPart);
        message.setCont ent(multipart);
        Transport.send( message);
        }

        catch (Exception e) {
        e.printStackTra ce();
        }
        }

        public String getReviewTime(D ate reviewDateTime, boolean flag)
        {
        Calendar c = Calendar.getIns tance();
        SimpleDateForma t s = new SimpleDateForma t("yyyyMMdd") ;
        c.setTime(revie wDateTime);

        if (flag)
        c.add(Calendar. MINUTE, 30);

        String hour = c.get(Calendar. HOUR_OF_DAY) < 10 ? "0"
        + c.get(Calendar. HOUR_OF_DAY) : ""
        + c.get(Calendar. HOUR_OF_DAY);
        String min = c.get(Calendar. MINUTE) < 10 ? "0" + c.get(Calendar. MINUTE)
        : "" + c.get(Calendar. MINUTE);
        String sec = c.get(Calendar. SECOND) < 10 ? "0" + c.get(Calendar. SECOND)
        : "" + c.get(Calendar. SECOND);
        String date = s.format(new Date(c.getTimeI nMillis()));
        String dateTime = date + "T" + hour + min + sec + "Z";
        return dateTime;
        }

        private class ByteArrayDataSo urce implements DataSource
        {
        private byte[] data; // data for mail message

        private String type; // content type/mime type
        ByteArrayDataSo urce(String data, String type)
        {
        try
        {
        // Assumption that the string contains only ascii
        // characters ! Else just pass in a charset into this
        // constructor and use it in getBytes()
        this.data = data.getBytes(" iso-8859-1");
        }
        catch (Exception e)
        {
        e.printStackTra ce();
        }
        this.type = type;
        }

        // DataSource interface methods
        public InputStream getInputStream( ) throws IOException
        {
        if (data == null)
        throw new IOException("no data exception in ByteArrayDataSo urce");
        return new ByteArrayInputS tream(data);
        }

        public OutputStream getOutputStream () throws IOException
        {
        throw new IOException("il legal operation in ByteArrayDataSo urce");
        }

        public String getContentType( )
        {
        return type;
        }

        public String getName()
        {
        return "dummy";
        }
        }

        Regards,
        Vidi

        Comment

        • techdisc
          New Member
          • Apr 2010
          • 1

          #5
          Thank you, your post was very helpful. I could manage to send meeting request using the code you posted.

          Comment

          Working...