Click here to Skip to main content
Click here to Skip to main content
Go to top

Adding Updating Calendar,Tasks Appointment using CDO Object

, 30 Nov 2007
Rate this:
Please Sign up or sign in to vote.
How to Add or Update Exchange Calendar/Tasks files using CDOAppointment object

Introduction

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 = "http://100.100.100.10/Exchange/test/Calendar/213.eml" 
ADOExchangeConn.Provider = "ExOLEDB.DataSource"
ADOExchangeConn.Open(MailBoxURL, ExchangeUserName, ExchangePassword, 0)

The MailBoxURL can be described as follows:

  • 100.100.100.10 - 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:

CDO.CdoDAV.cdoContentClass.Equals("urn:content-classes:appointment")
 
objCDOApp.Fields.Item(http://schemas.microsoft.com/exchange/outlookmessageclass).Value =
    "IPM.Appointment"

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
 objCDOApp.Fields.Update()  

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

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

History

  • 30th November, 2007: Initial post

License

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

Share

About the Author

Hrushikesh Mokashi
Web Developer
India India
No Biography provided

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web02 | 2.8.140926.1 | Last Updated 30 Nov 2007
Article Copyright 2007 by Hrushikesh Mokashi
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid