Click here to Skip to main content
15,848,415 members
Articles / Desktop Programming / Windows Forms

Adding Updating Calendar,Tasks Appointment using CDO Object

Rate me:
Please Sign up or sign in to vote.
2.71/5 (5 votes)
30 Nov 2007CPOL 29.2K   10  
How to Add or Update Exchange Calendar/Tasks files using CDOAppointment object


This article describes how to add or update Calendar/Tasks Appointment items using the CDO Appointment object.

Using the Code

Open the Exchange Server connection:

Dim ADOExchangeConn as new ADODB.Connection
Dim MailBoxUrl as string = "" 
ADOExchangeConn.Provider = "ExOLEDB.DataSource"
ADOExchangeConn.Open(MailBoxURL, ExchangeUserName, ExchangePassword, 0)

The MailBoxURL can be described as follows:

  • - Exchange IP Address
  • Exchange - Server Name
  • test - User Name
  • Calendar - Folder
  • 231.eml - eml filename

Define the CDO Appointment object:

Dim objCDOApp as CDO.Appointment

To add subject, we need to set:

objCDOApp.Fields.Item( =

Then, set subject as follows:

objCDOApp.Subject = sDisplayName
objCDOApp.Priority = 0
objCDOApp.AllDayEvent = True
objCDOApp.BusyStatus = "FREE"
objCDOApp.Duration = 86400
objCDOApp.Fields("urn:schemas:calendar:reminderoffset").Value = 64800
'''we can also Set objCDOApp.Fields("ReminderOffSet").Value = 64800

If event is a One Day event, then StartTime should be like "Date 00:00:00 AM", otherwise Calendar will show the same event (appointment) on two successive dates. Also, converting date to GMT is necessary:

Dim dtTemp1 As Date = DatePart(DateInterval.Month, strStartTime) & "/" & _
                               DatePart(DateInterval.Day, strStartTime) & "/" & _
                               DatePart(DateInterval.Year, strStartTime) & 
                               " 00:00:00 AM"
Dim iGmtDiff As Double = 
    DateDiff(DateInterval.Minute, System.DateTime.UtcNow(), System.DateTime.Now())
Dim dtTemp2 As Date = DateAdd(DateInterval.Minute, -iGmtDiff, dtTemp1)
objCDOApp.StartTime = dtTemp2.Date                   
dtTemp2 = DateAdd(DateInterval.Day, 1, dtTemp2)
objCDOApp.EndTime = dtTemp2.Date
 objCDOApp.Contact = "H"
 objCDOApp.TextBody = "There is meeting today with H"
 // This line is required to update objCDOApp.Fields("ReminderOffSet").Value = 600

Use the "var" button to wrap Variable or class names in <code> tags like this:

 objCDOApp.DataSource.SaveTo(MailboxUrl, , ADODB.ConnectModeEnum.adModeReadWrite, 
    ADODB.RecordOpenOptionsEnum.adOpenSource,  exchangeusername, exchangepwd)
'''  'SaveTo' function adds new eml also updates if the eml exists.


  • 30th November, 2007: Initial post


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Web Developer
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

-- There are no messages in this forum --