Friday, August 20, 2010

Creating Outlook Calendar Appointment with Powerbuilder

Microsoft Outlook is a popular Personal Information Management application. It is part of Microsoft Office package, which many users use it. Fortunately, Microsoft, as the maker Microsoft Outlook, has prepared the SDK to allows programmers to create their own applications that can interact seamlessly into the application Microsoft Outlook

One of the Outlook's feature is Calendar which it make possible to user to create their own schedule and will remind for it. It's very useful for people who has many schedules in their life.

In this part of session, I will try to explain how to insert or create a new appointment in outlook, programmatically, with Powerbuilder. One thing you should learn and know is Outlook Object Model, which you can find at Microsoft's MSDN site

Microsoft has prepared the AppointmentItem Class which has many properties, to create a new Appointment Object in Microsoft Outlook Calendar. Some properties that are commonly used for the calendar class are: Subject, Start, Duration, and Reminder.

First, you (or PC clients) must has Microsoft Outlook installed. Then at the script, you must declare OleObject variable type, than try to create the object and connect to Microsoft Outlook Object. In this example, I'm using Microsoft Outlook 2007 and Powerbuilder 6.5. Here's the full script to create a new Appointment Object:

1:  // declare OleObject variable and Constant Variable  
2:  oleobject oleOutlook  
3:  oleobject oleAppt  
4:  Constant Integer olAppointmentItem = 1  
6:  // create the Object  
7:  oleOutlook = create oleobject  
9:  // Connect To the Outlook Object  
10:  oleOutlook.ConnectToNewObject ('Outlook.Application')  
12:  // Create the Appointment Object  
13:  oleAppt = oleOutlook.CreateItem (olAppointmentItem)  
15:  // Set some common properties of Appointment Object  
16:  oleAppt.Location = "Home"  
17:  oleAppt.Subject = "Watch Fulham vs Manchester United Live"  
18:  oleAppt.Start = "08/21/2010 19:00"  
19:  oleAppt.ReminderMinutesBeforeStart = 1 // in minute  
20:  oleAppt.Duration = 120 // in minute  
21:  oleAppt.Body = "Go MU !!! Go !!!"  
23:  // Save the Appointment  
24:  oleAppt.Save  

And here the result of the example:

1 comment :

  1. Hi,

    This was very useful! Could you please post, how it's possible to send mails with Powerbuilder via Outlook 2007.

    Thank you for your help in advance.