Apr 162005
 

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?

 Posted by at 01:21