Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

outlook,auto appointment COLOR

Status
Not open for further replies.

shumi99

Programmer
Mar 3, 2010
30
US
Hi,

I have this simple code which works great (too auto add an appointment) but I would like it so that it makes it a "blue color". any quick fix?

here is the code:

oOut = CREATEOBJECT("outlook.application")
oAppItem = oOut.CreateItem(1)
oAppItem.start = {^2010-03-05 15:00:00}
oAppItem.end = {^2010-03-05 16:00:00}
oAppItem.subject = "DSL Install"
oAppItem.body = "Stuff here for body of message"
oAppItem.Location = "Client Premise"
oAppItem.save


any quick way of adding the "color" to it?

Thanks guys,
Schumi!
 
Shamelessly ripped from elsewhere (foxite) as you could tell from the comments.

After saving, pass the oAppItem and a color (1-10) to the following code:

Code:
PROCEDURE SetAppointmentLabelColour( toApp   AS Outlook.AppointmentItem, ;
                                     tnColor AS Integer )
    *-- Original VBA code by Sue Mosher, converted to VFP by S.Arnold.
    *-- Requires CDO 1.21
    LOCAL lcCDOPropSetID1 AS String, lcCDOAppt_Color AS String
    LOCAL loCDO    AS MAPI.Session
    LOCAL loMsg    AS MAPI.Message
    LOCAL loFields AS MAPI.Fields
    LOCAL loField  AS MAPI.Field
    LOCAL lcMsg    AS String
 
    lcCDOPropSetID1  = "0220060000000000C000000000000046"
    lcCDOAppt_Colors = "0x8214"
 
    loCDO = CREATEOBJECT('MAPI.Session')
    loCDO.Logon(,,.F.,.F.)
    IF !EMPTY(toApp.EntryID)
        loMsg    = loCDO.GetMessage(toApp.EntryID,toApp.Parent.StoreID)
        loFields = loMsg.Fields
        loField  = loFields.Item(lcCDOAppt_Colors,lcCDOPropSetID1)
        IF ISNULL(loField)
            && The 3 in the parameters represents vbLong type.
            loField = loFields.Add(lcCDOAppt_Colors,3,tnColor,lcCDOPropSetID1)
        ELSE
            loField.Value = tnColor
        ENDIF
        loMsg.Update(.T.,.T.)
    ENDIF
    loMsg    = .NULL.
    loFields = .NULL.
    loField  = .NULL.
    loCDO.Logoff
    loCDO = .NULL.
ENDPROC
 
Too hot!!!

Like a charm!

Thanks Guys!!

:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top