Access and Outlook Appointment Label

  • Thread starter Thread starter keri
  • Start date Start date
K

keri

Hi,

I have read previous posts about this but I am struggling to find an
answer that works for me - so my apologies in advance for duplicating a
previous post. I am a beginner to access but can mostly write and
understand basic code myself.

I have code from access that posts appointments to outlook (this works
fine). I want to change the label colour of appointments I post and
understand this is not as easy as changing other appointment
properties.

I have read posts with code to change the label colour that refer to
CDO and other things I have not heard of! I also could not fully
understand what the code was doing - therefore I am hesitant to use it
until I can comprehend what it is for, and so I can adapt it to my own
uses.

I would really appreciate anyone who could explain to me in basic
language the method for changing this label colour from access, and
where I can find information on this method. (Like I say I have seen
posts with the code other people have used to do this but I really
would like to understand how to do it before purely ripping off
somebodies code!)

Many thanks in advance to anyone who can help / advise me on this topic.
 
Hello again. Just to expand.

I have read definitions now of CDO and MAPI (though it is still not
entirely clear).
I have used code to GET the colour value such as below;

Sub GetColorCode()
Const CdoPropSetID1 = "0220060000000000C000000000000046"
Const CdoAppt_Colors = "0x8214"
Dim objAppt As Outlook.AppointmentItem
Dim objItem
Dim objExpl As Outlook.Explorer
Dim objCDO As MAPI.Session
Dim objMsg As MAPI.Message
Dim colFields As MAPI.Fields
Dim objField As MAPI.Field
Set objCDO = CreateObject("MAPI.Session")
objCDO.Logon "", "", False, False
Set objExpl = Application.ActiveExplorer
Set objItem = objExpl.Selection.Item(1)
If objItem.Class = olAppointment Then
Set objMsg = objCDO.GetMessage(objItem.EntryID,
objItem.Parent.StoreID)
Set colFields = objMsg.Fields
Set objField = colFields.Item(CdoAppt_Colors,
CdoPropSetID1)
'The objField.Value corresponds to the ordinal value of the

label
'1=Important, 2=Business, etc.
Debug.Print objField.Value
End If
End Sub

But i don't understand what this code is doing properly, and how I can
change it to SET the colour instead of printing it.

Thanks.
 
Hello again. Just to expand.

I have read definitions now of CDO and MAPI (though it is still not
entirely clear).
I have used code to GET the colour value such as below;

Sub GetColorCode()
Const CdoPropSetID1 = "0220060000000000C000000000000046"
Const CdoAppt_Colors = "0x8214"
Dim objAppt As Outlook.AppointmentItem
Dim objItem
Dim objExpl As Outlook.Explorer
Dim objCDO As MAPI.Session
Dim objMsg As MAPI.Message
Dim colFields As MAPI.Fields
Dim objField As MAPI.Field
Set objCDO = CreateObject("MAPI.Session")
objCDO.Logon "", "", False, False
Set objExpl = Application.ActiveExplorer
Set objItem = objExpl.Selection.Item(1)
If objItem.Class = olAppointment Then
Set objMsg = objCDO.GetMessage(objItem.EntryID,
objItem.Parent.StoreID)
Set colFields = objMsg.Fields
Set objField = colFields.Item(CdoAppt_Colors,
CdoPropSetID1)
'The objField.Value corresponds to the ordinal value of the

label
'1=Important, 2=Business, etc.
Debug.Print objField.Value
End If
End Sub

But i don't understand what this code is doing properly, and how I can
change it to SET the colour instead of printing it.

Thanks.
 
Programming questions like this are best posted in a programming group such
as microsoft.public.outlook.program_vba.

That CDO code sample, adapted from code posted by Randy Byrne, uses CDO to
access a property that is not exposed in the Outlook object model. CDO is a
lower level API that allows access to properties that aren't available to
the object model, such as the label and color.

That CDO property that's being constructed ends up reading the property that
in MAPI DASL syntax would be
"http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/82140003".

Reading that property you get back a Long value that indicates the color. If
you read further in the thread about that code you will see that to set the
property you need the color value you want to set and then somthing like
this would set it and save the change:

objField.Value = 2 ' Business - color Blue
objMsg.Update ' save the item

Debug.print doesn't print the value, it displays it in the Immediate window
in the VBA project.
 
Back
Top