Okay, I did it. Why this is so completely and utterly undocumented, I don’t know. There are no proper examples in C# (lot’s of VB.NET, but some methods take different arguments, some methods/properties don’t exist) to change the Appointment’s color (“label” in the Outlook-dialog) programmaticaly. So here goes, for your sake.
{
MAPI.Session myMAPISession = new MAPI.SessionClass();
object myMV = System.Reflection.Missing.Value;
myMAPISession.Logon("Microsoft Outlook Internet Settings",myMV,false,myMV,myMV,myMV,myMV);
MAPI.Message myMAPIMessage = (MAPI.Message)myMAPISession.GetMessage(Afspraak.EntryID,myMV);
MAPI.Fields myMAPIFields = (MAPI.Fields)myMAPIMessage.Fields;
MAPI.Field myApptLabel = (MAPI.Field)myMAPIFields.get_Item("0x8214","0220060000000000C000000000000046");
if(myApptLabel.Equals(null))
{
myApptLabel = (MAPI.Field)myMAPIFields.Add("0x8214","long",3,"0220060000000000C000000000000046");
}
else
{
myApptLabel.Value = 3;
}
myMAPIMessage.Update(true,true);
}
Now help me out: how can I change the hardcoded “Microsoft Outlook Internet Settings” to some constant or variable pointing at the default profile?
Hi, can you give me the parameters and the usings necessary to buil this function
so, i have found. But i have a problem with : Afspraak.EntryID (what is it ?)
My appointment object is a CDO.Appointment, so i can’t convert an outlook appointment in a CDO appointment
Afspraak.EntryID is a customfield.
Everything you need to know is in the above code. I’m not making an Open Source product, so this is as far as I’ll go providing code. I already have legal issues just because of this product.