Appointment Items in Public Folder calendar

  • Thread starter Thread starter baggers
  • Start date Start date
Status
Not open for further replies.
B

baggers

I am creating an application that displays appointments from a public folder

calendar, to expose XML that contains the appointment start date & time, and

the subject, etc.

The app could reside on the exchange server or on any other server that can

access the exchange server, but I'm trying to avoid using the Outlook

application to accomplish this, so I'm trying CDO/MAPI.

Here's the Scenario:

I create a Calendar in a Public Folder.

I add 15000 appointments in the calendar over a period of several years.

I know the EntryId and StoreID for the Calendar I've created (thanks

OutlookSpy).

Here is my sample code to date:

Private Sub VisualMapi()

Dim oSession As MAPI.Session

Dim oStores As MAPI.InfoStores

Dim oStore As MAPI.InfoStore

Dim oRoot As MAPI.Folder

Dim oFolders As MAPI.Folders

Dim oFolder As MAPI.Folder

Dim oMsgs As MAPI.Messages

Dim oItem As MAPI.MeetingItem

Dim oMsg As MAPI.Message

Dim oAppt As MAPI.AppointmentItem

Dim oFilter As MAPI.MessageFilter

Dim iLooper As Integer

Dim strFilter As String

lstAppointments.Clear

lblTrace.Caption = vbNullString

'create a session object if we don't have one already

If oSession Is Nothing Then

Set oSession = New MAPI.Session

'logon to the session

oSession.Logon

End If

'get a reference to the info stores collection

Set oStores = oSession.InfoStores

'check for error

If Not oStores Is Nothing Then

Set oFolder = oSession.GetFolder("{Entry ID}", "{Store ID}")

Debug.Print vbCrLf & "This is the Folder : " & oFolder.Name

End If

'get the messages collection of the folder

'make sure there's some folders there

If Not oFolder Is Nothing Then

'get a reference to the messages collection

Set oMsgs = oFolder.Messages

'make sure we have some messages

If Not oMsgs Is Nothing Then

'get the messages filter for the messages collection

' 'oFilter is used as the Filter object; it needs to be DIM'd in

your code

Set oFilter = oMsgs.Filter

'set filter criteria

Debug.Print vbCrLf & "-------Filter on the day 30/06/2009 @ " &

Now & " --------"

' oFilter.TimeFirst = CDate("30/06/2009 00:00:01")

' oFilter.TimeLast = CDate("30/06/2009 23:59:59")

'OR

' oFilter.Fields.Add CdoPR_START_DATE, CDate("28/06/2009")

' oFilter.Fields.Add CdoPR_END_DATE, CDate("27/06/2009")

Dim sRestrict As String

Dim dteDate As Date

Dim strWhere As String

dteDate = CDate(Now)

oMsgs.Sort CdoAscending, CdoPR_START_DATE

' strWhere = "Start = " & SingleQuote(Format(dteDate,

"yyyy-mm-dd") & " 00:00:00") & " AND Start < " & SingleQuote(Format(dteDate +

1, "yyyy-mm-dd") & " 00:00:00")

' sRestrict = "select * from Folder Where " & strWhere

sRestrict = "(" & DoubleQuote("urn:schemas:calendar:dtstart") &

" > " & SingleQuote("30/06/2009 00:00") & " AND " &

DoubleQuote("urn:schemas:calendar:dtstart") & " < " & SingleQuote("01/07/2009

00:00") & ")"

' sRestrict = " (%today(""urn:schemas:calendar:dtstart"")%)"

Debug.Print sRestrict

??? oFilter. (sRestrict)

'loop through all the filtered messages

For Each oMsg In oMsgs

'get information on each message

' If TypeOf oMsg Is MAPI.AppointmentItem Then

Debug.Print "START: " & oMsg.FolderID & vbTab &

"SUBJECT: " & oMsg.Subject '??? NEED to display the start date/time and

duration, as well as the subject.

' End If

Next

End If

End If

'empty all object references when done!

tidy_up:

oSession.Logoff

Set oSession = Nothing

Set oStores = Nothing

Set oStore = Nothing

Set oRoot = Nothing

Set oFolders = Nothing

Set oFolder = Nothing

Set oMsgs = Nothing

Set oMsg = Nothing

Set oAppt = Nothing

Set oFilter = Nothing

End Sub

I have a problem at the two lines marked with ???

1. I cannot get the filter to work (several methods attempted as you can see

from commented code)

2. I cannot access the Start, End, Duration properties through MAPI.Message

object, so how do I get a MAPI.AppointmentItem object populated?

We need each query to take no more than 3 seconds (or maybe 5 seconds at

most).

I am stumped, can anyone here offer any advice.

Thanks (in advance)
 
Please don't multipost. I answered your question in the

exchange.applications group.

"baggers" <simon.baguley@npbs.co.uk> wrote in message

news:236A1649-25C9-43F5-A258-28BC2449D031@microsoft.com...
> I am creating an application that displays appointments from a public
> folder
> calendar, to expose XML that contains the appointment start date & time,
> and
> the subject, etc.
> The app could reside on the exchange server or on any other server that
> can
> access the exchange server, but I'm trying to avoid using the Outlook
> application to accomplish this, so I'm trying CDO/MAPI.

> Here's the Scenario:
> I create a Calendar in a Public Folder.
> I add 15000 appointments in the calendar over a period of several years.
> I know the EntryId and StoreID for the Calendar I've created (thanks
> OutlookSpy).

> Here is my sample code to date:

> Private Sub VisualMapi()
> Dim oSession As MAPI.Session
> Dim oStores As MAPI.InfoStores
> Dim oStore As MAPI.InfoStore
> Dim oRoot As MAPI.Folder
> Dim oFolders As MAPI.Folders
> Dim oFolder As MAPI.Folder
> Dim oMsgs As MAPI.Messages
> Dim oItem As MAPI.MeetingItem
> Dim oMsg As MAPI.Message
> Dim oAppt As MAPI.AppointmentItem
> Dim oFilter As MAPI.MessageFilter

> Dim iLooper As Integer
> Dim strFilter As String

> lstAppointments.Clear
> lblTrace.Caption = vbNullString

> 'create a session object if we don't have one already
> If oSession Is Nothing Then
> Set oSession = New MAPI.Session
> 'logon to the session
> oSession.Logon
> End If
> 'get a reference to the info stores collection
> Set oStores = oSession.InfoStores
> 'check for error
> If Not oStores Is Nothing Then
> Set oFolder = oSession.GetFolder("{Entry ID}", "{Store ID}")
> Debug.Print vbCrLf & "This is the Folder : " & oFolder.Name
> End If
> 'get the messages collection of the folder
> 'make sure there's some folders there
> If Not oFolder Is Nothing Then
> 'get a reference to the messages collection
> Set oMsgs = oFolder.Messages
> 'make sure we have some messages
> If Not oMsgs Is Nothing Then
> 'get the messages filter for the messages collection
> ' 'oFilter is used as the Filter object; it needs to be DIM'd
> in
> your code
> Set oFilter = oMsgs.Filter
> 'set filter criteria
> Debug.Print vbCrLf & "-------Filter on the day 30/06/2009 @ " &
> Now & " --------"
> ' oFilter.TimeFirst = CDate("30/06/2009 00:00:01")
> ' oFilter.TimeLast = CDate("30/06/2009 23:59:59")
> 'OR
> ' oFilter.Fields.Add CdoPR_START_DATE, CDate("28/06/2009")
> ' oFilter.Fields.Add CdoPR_END_DATE, CDate("27/06/2009")

> Dim sRestrict As String
> Dim dteDate As Date
> Dim strWhere As String
> dteDate = CDate(Now)

> oMsgs.Sort CdoAscending, CdoPR_START_DATE
> ' strWhere = "Start = " & SingleQuote(Format(dteDate,
> "yyyy-mm-dd") & " 00:00:00") & " AND Start < " &
> SingleQuote(Format(dteDate +
> 1, "yyyy-mm-dd") & " 00:00:00")
> ' sRestrict = "select * from Folder Where " & strWhere
> sRestrict = "(" & DoubleQuote("urn:schemas:calendar:dtstart") &
> " > " & SingleQuote("30/06/2009 00:00") & " AND " &
> DoubleQuote("urn:schemas:calendar:dtstart") & " < " &
> SingleQuote("01/07/2009
> 00:00") & ")"
> ' sRestrict = " (%today(""urn:schemas:calendar:dtstart"")%)"
> Debug.Print sRestrict
> ??? oFilter. (sRestrict)
> 'loop through all the filtered messages
> For Each oMsg In oMsgs
> 'get information on each message
> ' If TypeOf oMsg Is MAPI.AppointmentItem Then
> Debug.Print "START: " & oMsg.FolderID & vbTab &
> "SUBJECT: " & oMsg.Subject '??? NEED to display the start date/time and
> duration, as well as the subject.
> ' End If
> Next
> End If
> End If

> 'empty all object references when done!
> tidy_up:
> oSession.Logoff
> Set oSession = Nothing
> Set oStores = Nothing
> Set oStore = Nothing
> Set oRoot = Nothing
> Set oFolders = Nothing
> Set oFolder = Nothing
> Set oMsgs = Nothing
> Set oMsg = Nothing
> Set oAppt = Nothing
> Set oFilter = Nothing
> End Sub

> I have a problem at the two lines marked with ???
> 1. I cannot get the filter to work (several methods attempted as you can
> see
> from commented code)
> 2. I cannot access the Start, End, Duration properties through
> MAPI.Message
> object, so how do I get a MAPI.AppointmentItem object populated?

> We need each query to take no more than 3 seconds (or maybe 5 seconds at
> most).

> I am stumped, can anyone here offer any advice.
> Thanks (in advance)
>
 
Sorry Ken, wasn't sure where the query belonged or if different experts might

be monitoring different discussion groups.

Won't do it again!
wrote:


> Please don't multipost. I answered your question in the
> exchange.applications group.

> >

>

> "baggers" <simon.baguley@npbs.co.uk> wrote in message
> news:236A1649-25C9-43F5-A258-28BC2449D031@microsoft.com...
> >I am creating an application that displays appointments from a public
> >folder
> > calendar, to expose XML that contains the appointment start date & time,
> > and
> > the subject, etc.
> > The app could reside on the exchange server or on any other server that
> > can
> > access the exchange server, but I'm trying to avoid using the Outlook
> > application to accomplish this, so I'm trying CDO/MAPI.
> > Here's the Scenario:
> > I create a Calendar in a Public Folder.
> > I add 15000 appointments in the calendar over a period of several years.
> > I know the EntryId and StoreID for the Calendar I've created (thanks
> > OutlookSpy).
> > Here is my sample code to date:
> > Private Sub VisualMapi()
> > Dim oSession As MAPI.Session
> > Dim oStores As MAPI.InfoStores
> > Dim oStore As MAPI.InfoStore
> > Dim oRoot As MAPI.Folder
> > Dim oFolders As MAPI.Folders
> > Dim oFolder As MAPI.Folder
> > Dim oMsgs As MAPI.Messages
> > Dim oItem As MAPI.MeetingItem
> > Dim oMsg As MAPI.Message
> > Dim oAppt As MAPI.AppointmentItem
> > Dim oFilter As MAPI.MessageFilter
> > Dim iLooper As Integer
> > Dim strFilter As String
> > lstAppointments.Clear
> > lblTrace.Caption = vbNullString
> > 'create a session object if we don't have one already
> > If oSession Is Nothing Then
> > Set oSession = New MAPI.Session
> > 'logon to the session
> > oSession.Logon
> > End If
> > 'get a reference to the info stores collection
> > Set oStores = oSession.InfoStores
> > 'check for error
> > If Not oStores Is Nothing Then
> > Set oFolder = oSession.GetFolder("{Entry ID}", "{Store ID}")
> > Debug.Print vbCrLf & "This is the Folder : " & oFolder.Name
> > End If
> > 'get the messages collection of the folder
> > 'make sure there's some folders there
> > If Not oFolder Is Nothing Then
> > 'get a reference to the messages collection
> > Set oMsgs = oFolder.Messages
> > 'make sure we have some messages
> > If Not oMsgs Is Nothing Then
> > 'get the messages filter for the messages collection
> > ' 'oFilter is used as the Filter object; it needs to be DIM'd
> > in
> > your code
> > Set oFilter = oMsgs.Filter
> > 'set filter criteria
> > Debug.Print vbCrLf & "-------Filter on the day 30/06/2009 @ " &
> > Now & " --------"
> > ' oFilter.TimeFirst = CDate("30/06/2009 00:00:01")
> > ' oFilter.TimeLast = CDate("30/06/2009 23:59:59")
> > 'OR
> > ' oFilter.Fields.Add CdoPR_START_DATE, CDate("28/06/2009")
> > ' oFilter.Fields.Add CdoPR_END_DATE, CDate("27/06/2009")
> > Dim sRestrict As String
> > Dim dteDate As Date
> > Dim strWhere As String
> > dteDate = CDate(Now)
> > oMsgs.Sort CdoAscending, CdoPR_START_DATE
> > ' strWhere = "Start = " & SingleQuote(Format(dteDate,
> > "yyyy-mm-dd") & " 00:00:00") & " AND Start < " &
> > SingleQuote(Format(dteDate +
> > 1, "yyyy-mm-dd") & " 00:00:00")
> > ' sRestrict = "select * from Folder Where " & strWhere
> > sRestrict = "(" & DoubleQuote("urn:schemas:calendar:dtstart") &
> > " > " & SingleQuote("30/06/2009 00:00") & " AND " &
> > DoubleQuote("urn:schemas:calendar:dtstart") & " < " &
> > SingleQuote("01/07/2009
> > 00:00") & ")"
> > ' sRestrict = " (%today(""urn:schemas:calendar:dtstart"")%)"
> > Debug.Print sRestrict
> > ??? oFilter. (sRestrict)
> > 'loop through all the filtered messages
> > For Each oMsg In oMsgs
> > 'get information on each message
> > ' If TypeOf oMsg Is MAPI.AppointmentItem Then
> > Debug.Print "START: " & oMsg.FolderID & vbTab &
> > "SUBJECT: " & oMsg.Subject '??? NEED to display the start date/time and
> > duration, as well as the subject.
> > ' End If
> > Next
> > End If
> > End If
> > 'empty all object references when done!
> > tidy_up:
> > oSession.Logoff
> > Set oSession = Nothing
> > Set oStores = Nothing
> > Set oStore = Nothing
> > Set oRoot = Nothing
> > Set oFolders = Nothing
> > Set oFolder = Nothing
> > Set oMsgs = Nothing
> > Set oMsg = Nothing
> > Set oAppt = Nothing
> > Set oFilter = Nothing
> > End Sub
> > I have a problem at the two lines marked with ???
> > 1. I cannot get the filter to work (several methods attempted as you can
> > see
> > from commented code)
> > 2. I cannot access the Start, End, Duration properties through
> > MAPI.Message
> > object, so how do I get a MAPI.AppointmentItem object populated?
> > We need each query to take no more than 3 seconds (or maybe 5 seconds at
> > most).
> > I am stumped, can anyone here offer any advice.
> > Thanks (in advance)
> >


>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
M using excel to sort outlook appointment items Outlook VBA and Custom Forms 4
S Display PF contact folder items to select contact to link to appointment Outlook VBA and Custom Forms 1
Y Q's on Appointment Reminders Using Outlook 2
V VBA Categories unrelated to visible calendar and Visual appointment Categories Outlook VBA and Custom Forms 2
F Add a category before "Send an Email When You Add an Appointment to Your Calendar" Outlook VBA and Custom Forms 0
B Linking contact to an Appointment Using Outlook 1
S Appointment font size when printing only changes Tasks' font Using Outlook 0
D Copy Appointment Body to Task Body Outlook VBA and Custom Forms 0
S New Outlook Appointment - Select All Body Text and Change Font and Size Outlook VBA and Custom Forms 1
e_a_g_l_e_p_i Outlook 2010 How can I change the font size on right side appointment pane Using Outlook 12
Chiba Create an appointment for all the members Outlook VBA and Custom Forms 1
D Prevent popup of "Do you want to save changes?" when closing after opening an appointment to view Outlook VBA and Custom Forms 2
O Calendar - appointment templates and categories Using Outlook 1
W Appointment userproperties disappear Outlook VBA and Custom Forms 4
Nessa Can't create new appointment Using Outlook 1
F Appointment Show All Fields Using Outlook 1
C Trying to populate an appointment ComboBox from Excel Outlook VBA and Custom Forms 2
A Possible to hide ribbon with custom appointment form? Outlook VBA and Custom Forms 3
W Appointment occurrences change the location property Using Outlook 0
W Space in an Outlook appointment body Using Outlook 0
Dave A Run macro on existing appointment when it changes Outlook VBA and Custom Forms 1
JoeG Appointment Delete/Change Recurrence Outlook VBA and Custom Forms 0
M Forward Appointment as BCC with VBScript Outlook VBA and Custom Forms 7
K Update Appointment category when changed in Excel Using Outlook 3
S View Appointment in Text Wrap in Outlook 2007 Month Calendar View Using Outlook 0
A Day view - print appointment details Using Outlook 1
R Recover Deleted Appointment in Calendar Using Outlook 0
N Select Appointment subject line from combobox or list Outlook VBA and Custom Forms 1
S Appointment-Cannot set Categories because ConversationID is not set Outlook VBA and Custom Forms 1
D Record Appointment to Calendar on "Public Folder" Outlook VBA and Custom Forms 13
G Copy Contact field to Appointment Custom Form Field Outlook VBA and Custom Forms 2
G How to Copy Multi Select Listbox Data to Appointment Outlook VBA and Custom Forms 3
S Appointment colour categories disappear Using Outlook 4
G Using Data From Combo Box in Appointment Body Outlook VBA and Custom Forms 6
C Set reminder / appointment by right clicking email Using Outlook 1
A Add attachments to appointment based on field values Outlook VBA and Custom Forms 0
S how to set user properties to a newly created appointment Outlook VBA and Custom Forms 12
Y Creating custom appointment request form with multiple mail recipients Outlook VBA and Custom Forms 5
S my vbscript button1_click code works on appointment created but not on opening an existing apntmn Outlook VBA and Custom Forms 16
G Create an Appointment at the Contact's Address From Email Outlook VBA and Custom Forms 0
Diane Poremsky Create Task or Appointment and Insert Selected Text Using Outlook 0
Pierce007 Maps/location in making an appointment Using Outlook 2
A Get shared calendar name or id in custom appointment form Using Outlook 0
Diane Poremsky Create Appointment From Email Automatically Using Outlook 0
C Reminder for single-click appointment Using Outlook 2
P Appointment times are off by one minute Using Outlook 1
M receive mail when appointment category changes and create task from appointment Outlook VBA and Custom Forms 0
B VBA Code to create appointment from email Outlook VBA and Custom Forms 1
Diane Poremsky Create an Outlook appointment from an email message Using Outlook 4
Diane Poremsky Create an Appointment Diary Using Outlook 0

Similar threads

Back
Top