Flagging Your Contacts With Code

UPDATE, 8/9/2004: There was a bug in my code!  I was forgetting to set CdoPR_REMINDER_SET to ‘True’; thanks to Fred for pointing out the error, and to Dmitry for soothing my brain cramp by pointing out I that have to use CdoPropSetID4 when setting that property.  All modifications of the code since the last post are preceded with ‘** comments on the previous line.

Why, oh WHY, does working with flag information for Contacts in VBA differ so greatly compared with MailItem or MeetingItem objects? I don’t know! But they do! It’s easy for those objects:

objMail.FlagStatus = olFlagMarked
objMail.FlagRequest = “Follow up”
objMail.FlagDueBy = “05/27/2004 15:30 PM”

That’s all there is to it! But those Flag_ properties do not exist for ContactItems. You need to use CDO and some undocumented methods to save these values.

The necessary CDO properties that you need to work with are obvious at first: CdoPR_FLAG_TEXT, CdoPR_FLAG_STATUS, CdoPR_FLAG_DUE_BY and CdoPR_REMINDER_SET.  However, the sneaky bits are the other properties that you have to set that are non-intuitive: CdoPR_REPLY_REQUESTED, CdoPR_RESPONSE_REQUESTED, CdoPR_FLAG_DUE_BY_NEXT and CdoPR_REPLY_TIME.

Put the code below into a Module in your Outlook VBA project, making sure that you have a reference set to the Microsoft CDO 1.21 library. Then select any test Contact and run the procedure to see how the flag information is manipulated. Modify the code to suit any solution that you need it for.

Eric Legault

Full-stack product builder & consultant for Microsoft 365 & Graph. Microsoft MVP 2003 - 2019. Outlook add-in guru. Rocker. Video/audio engineer. Collects Thors.

You may also like...

%d bloggers like this: