Appointment item properties

D

dxider

Hi, im programming an AddIn that gets information abount appointment items
and saves un-sync items to a SQL Server DataBase. All is working ok, but now
I'm trying to get the appointment label text and can't find the exact method
or propertie to get this information. If someone knows hot to get the Label
text, please let me know, I´ve tried for about 3 days and not answer in all
the internet.

Thanks in advance.
 
D

dxider

Thanks a lot for your help, I still can't get the appointment's label text,
I'm thinking in implementing custom properties to solve this issue.
 
K

Ken Slovak - [MVP - Outlook]

There is no property that holds an appointment's label text. The property
(not exposed in the Outlook object model) is a 32-bit integer that is part
of an enumeration. All you get is a value from the enumeration that
corresponds to the label color and text. For example, None = 0, Important =
1, Business = 2, etc.

The property is a named property that can be retrieved in Outlook 2007 using
the DASL property tag of
"http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/82140003"
(note that this is a string DASL property tag and not a URL).

You can retrieve this property using an alternate API such as CDO 1.21 or
Redemption (www.dimastr.com/redemption), but not when using the Outlook
object model, except in Outlook 2007, where you can use that DASL property
tag with the PropertyAccessor object for the appointment item.
 
D

dxider

I almost forgot to share with you the final solution of this problem, this
are the 2 functions needed:

using nov=System.Reflection.Missing;

// Get the index of selected label for the appointment
private int getLabel(AppointmentItem actividad)
{
MAPI.Session ses = new MAPI.Session();
ses.Logon(nov.Value, nov.Value, false, false, nov.Value,
nov.Value, nov.Value);
MAPI.Message mens =
(MAPI.Message)ses.GetMessage(actividad.EntryID, nov.Value);
MAPI.Fields campos = (MAPI.Fields)mens.Fields;
MAPI.Field campo = (MAPI.Field)campos.get_Item("0x8214",
"0220060000000000C000000000000046");
int label = int.Parse(campo.Value.ToString());
ses.Logoff();
return label;
}

// Retur the label text according with the index passed
private string setLabel(int numero)
{
string etiqueta = "";
switch (numero)
{
case 1:
etiqueta = "PLANEACIÓN Y SEGUIMIENTO";
break;
case 2:
etiqueta = "ANÃLISIS";
break;
case 3:
etiqueta = "DISEÑO";
break;
case 4:
etiqueta = "DESARROLLO";
break;
case 5:
etiqueta = "REPROCESO";
break;
case 6:
etiqueta = "PRUEBAS";
break;
case 7:
etiqueta = "INVESTIGACIÓN Y CAPACITACIÓN";
break;
case 8:
etiqueta = "DESPLIEGUE Y SOPORTE AL CLIENTE";
break;
case 9:
etiqueta = "INTERRUPCIONES";
break;
case 10:
etiqueta = "Personal";
break;
}
return etiqueta;
}

To get the appointment Label, just install CDO 1.2.1 from Microsoft, add a
reference to the project and use this function call:

string label="";
label=setLabel(getLabel(appointmentObject));

Just change the code inside the switch in the setLabel function, to work
according to your Outlook label definitions.
 
K

Ken Slovak - [MVP - Outlook]

Please be advised that for managed code CDO 1.21 is not supported at all. It
might appear to work correctly, for a while and in various tests, but there
are memory leaks and problems in memory management that make this a
non-supported solution. Not a good idea at all.

If Outlook 2007 is being used one can use the PropertyAccessor object to
replace any CDO code, if not a 3rd party COM wrapper over MAPI such as
Redemption (www.dimastr.com/redemption) is the preferred way.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top