Outlook Meeting Request from webMethods

Hello,

Is it possible to send outlook meeting request from webmethods ? If there is any way , can you please share the ideas !!

Thanks,

Hi,

I couldn’t say that I did it fully. The following code is sending the meeting request as an attachment. I am still looking where and how to make changes so that it sends a ‘complete meeting request’. I am posting the code here so that you and others also work together to comeout with a tangible java service that sends meeting request. May be this is a good time to do some R & D .

Create a java service and import the below packages:

[FONT=Courier New]import java.io.InputStream;
import java.io.OutputStream;
import java.io.StringBufferInputStream; 
import java.text.SimpleDateFormat; 
import java.util.Date;
import java.util.Properties; 
import javax.activation.DataHandler; 
import javax.activation.DataSource; 
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;[/font]
[FONT=Courier New]import javax.mail.internet.MimeBodyPart.*;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;[/font]
[FONT=Courier New]import java.io.*;[/font]
[FONT=Courier New]import java.lang.*;[/font]
[FONT=Courier New]import java.util.*;[/font]

May be there are unused packages in the above list.

In the ‘source’ section under ‘shared’ tab add the below code:

[FONT=Courier New]private static class StrDataSource implements DataSource{
        private String contents ;
        private String mimetype ;
        private String name ;
 
 
        public StringDataSource( String contents
                               , String mimetype
                               , String name
                               ) {
            this.contents = contents ;
            this.mimetype = mimetype ;
            this.name = name ;
        } 
 
        public String getContentType() {
            return( mimetype ) ;
        }
 
        public String getName() {
            return( name ) ;
        }
 
        public InputStream getInputStream() {
            return( new StringBufferInputStream( contents ) ) ;
        }
 
        public OutputStream getOutputStream() throws ServiceException {
            throw new ServiceException( "This datasource cannot be written") ;
        }
    }
[/font]

in the actual code write this:

[FONT=Courier New]
 IDataCursor pipelineCursor = pipeline.getCursor();
 String host = IDataUtil.getString( pipelineCursor, "smtpHost" );
    String port = IDataUtil.getString( pipelineCursor, "smtpPort" );
    String sender = IDataUtil.getString( pipelineCursor, "from" );
    String subject = IDataUtil.getString( pipelineCursor, "subject" );
 String[] to = IDataUtil.getStringArray(pipelineCursor,"to");
 String location = IDataUtil.getString( pipelineCursor, "location" );
 String invitationId = IDataUtil.getString( pipelineCursor, "invitationId" );
 String start = IDataUtil.getString( pipelineCursor, "startTime" );
 String end = IDataUtil.getString( pipelineCursor, "endTime" );
 String description = IDataUtil.getString( pipelineCursor, "description" );
 
   try {
            Properties prop = new Properties();
           // prop.put("mail.smtp.port", port );
            prop.put("mail.smtp.host", host );
 
            Session session = Session.getInstance(prop);
            session.setDebug(true);
 
            // Define message
            MimeMessage message = new MimeMessage(session);
   message.setFrom(new InternetAddress(sender));
            //message.setFrom(new InternetAddress("[EMAIL="tgunasekhar@gmail.com"]tgunasekhar@gmail.com[/EMAIL]"));
 
            // Set TO
            if( to != null && ( to.length > 0 ) ) {
                InternetAddress[] address = new InternetAddress[ to.length ] ;
 
                for( int i = 0; i < to.length; i++ ) {
                    address[ i ] = new InternetAddress( to[ i ] ) ;
                }
 
                message.setRecipients( Message.RecipientType.TO, address ) ;
            }
 
            // Set subject
            message.setSubject(subject);
 
            // Create iCalendar message
            StringBuffer messageText = new StringBuffer();
            messageText.append("BEGIN:ICALENDAR\n" +
                               "PRODID:-//Microsoft Corporation//Outlook 9.0 MIMEDIR//EN\n" +
                               "VERSION:2.0\n" +
                               "METHOD:REQUEST\n" +
                                   "BEGIN:VEVENT\n" +
                                   "ORGANIZER:MAILTO:" ) ;
            messageText.append( sender ) ;
            messageText.append( "\n" +
                                "DTSTART:");
            messageText.append(  start ) ;
            messageText.append( "\n" +
                                "DTEND:" ) ;
            messageText.append(  end  ) ;
            messageText.append( "\n" +
                                "LOCATION:" ) ;
            messageText.append( location ) ;
            messageText.append( "\n" +
                                 "UID:" ) ;
            messageText.append( invitationId ) ;
            messageText.append( "\n" +
                                "DTSTAMP:" ) ;
            messageText.append( dateFormat.format( new java.util.Date() ) ) ;
            messageText.append( "\n" +
                                "DESCRIPTION;ALTREP=\"CID:<eventDescriptionHTML>\"" ) ;
            messageText.append( "\n" +
                                        "BEGIN:VALARM\n" +
                                        "TRIGGER:-PT15M\n" +
                                        "ACTION:DISPLAY\n" +
                                        "DESCRIPTION:Reminder\n" +
                                        "END:VALARM\n" +
                                   "END:VEVENT\n" +
                               "END:VCALENDAR"
                               ) ;
 
            Multipart mp = new MimeMultipart();
 
            MimeBodyPart meetingPart = new MimeBodyPart() ;
            meetingPart.setDataHandler( new DataHandler( new StrDataSource( messageText.toString(), "text/calendar", "meetingRequest" ) ) ) ;
            mp.addBodyPart( meetingPart ) ;
 
            MimeBodyPart descriptionPart = new MimeBodyPart() ;
            descriptionPart.setDataHandler( new DataHandler( new StrDataSource( description, "text/html", "eventDescription" ) ) ) ;
            //descriptionPart.setContentID( "<eventDescriptionHTML>" ) ;
            mp.addBodyPart( descriptionPart ) ;
 
            message.setContent( mp ) ;
 
            // send message
            Transport.send(message);
 
        } 
  catch (MessagingException me) 
  {
            throw new ServiceException(me);
 
        } 
  catch (Exception ex) 
  {
            throw new ServiceException(ex);
 
        }
 
   [/font]

Declare all the inputs for the service.

I don’t know how many changes are needed. If somebody can put some effort and come up with a solution that would be great.
The other option could be using the Outlook COM component in webMethods (I really didn’t try yet) with WmWin32 package.

Cheers:)
Guna

Hi Gunasekhar,

Thanks for your reply …
I got this without going to java service , rather use couple of webMethods built in services from WmPublic/pub/mime folder to build mime body that outlook recognizes as a meetingRequest rather than an ordinary email … and then send it using regular pub/client/smtp service …

hey
can u please explain in detail please

  1. set the emailBody as in the attached file (hard code this variable)
    2)pub.mime:createMimeData (Dont give any inputs(serviceIn blank)
    3)stringToStream (pass email body as input to this)
    4)pub.mime:addBodyPart (inputs :: mimeData - takes from previous step
    content - Stream (bytes) which you converted in
    the above step)
    contentType - hardcode it as text/calendar)
    5)pub.mime:getEnvelopeStream (input - mimeData)
    6)pub.client:smtp (inputs - mailhost
    mimeStream (map from “envStream” which you
    will get in the above step
    to (email-id’s to whom you want to send the
    meeting request)

Hope this helps … Let me know if its not clear …
emailBody.txt (1.43 KB)

hey…
i tried to build this flow service but somehow it isnt working…
im getting the mail but the mail is blank…
any suggestions??

Hussain,

Hope you are substituting all the variables in the "emailBody" which you are setting in the First step... and some facts about those variables .....
  1. The datetime stamps should be in the following formats and should be in GMT …Sample is as follows…

DTSTAMP:20080507T140000Z
DTSTART:20080408T140000Z (Meeting start time)
DTEND:20080408T150000Z (Meeting end time)

2)UID:{%newGUID%} - Should always be Unique (Check about GUIDs) – To test , You can have some random value for testing purposes…

Hope this helps !!!

thanx a lot.

Hi All,

I need to know the steps to send a complete meeting request without sending the calendar which is sent as attachment.
Can you please help me with the steps.

Thanks And Regards,
Agila.