Discussion:
How can I effectively create and save UserProperties in Outlook?
(too old to reply)
rventuradiaz
2010-04-22 12:53:10 UTC
Permalink
I am trying to create and add UserProperty in a calendar's subfolder.
Code for creation works fine. However when I develop and debug code
for checking UserProperty, I found nothing was added. ¿Would you help
me to solve this issue, please?

I used the following code for set meeting: BEGIN
***************************************************************************

Dim olAppt As Outlook.AppointmentItem
Set olAppt = objSubCalFolder.Items.Add ' Mod 14-ABR-2010; Establece
el método Add en la Subcarpeta

Dim actField As UserProperty
Set actField = olAppt.UserProperties.Add("actId", olNumber) 'Set
UserProperty


' Set appointment start and end
olAppt.Start = FecIni + CDbl(HorIni)
olAppt.End = FecFin + CDbl(HorIni) / 24# + CDbl(Duracion) / 60# / 24#
Set myRecurrPatt = olAppt.GetRecurrencePattern
myRecurrPatt.RecurrenceType = olRecursDaily
myRecurrPatt.PatternStartDate = FecIni
myRecurrPatt.PatternEndDate = FecFin

' Configurar la información de otra cita...
With olAppt
.Duration = Duracion
.Subject = Asunto
.Body = "Reserva de Aula para actividad: " & Asunto
.Location = "Oficina doméstica"
.ReminderMinutesBeforeStart = 60
.ReminderSet = True

'Is set value for property actId
.UserProperties("actId") = actCode End With

' Guardar la cita...
olAppt.Save
****************************************************************************************************************************
END

Until here, I works fine... However, when I develop and test the code
to check the UserProperty value, then return nothing value, meaning
there is no UserProperties. Here is the code:

Code for check UserProperty: BEGIN
****************************************************************************************

Dim olAppt As Outlook.AppointmentItem
Dim olApptUserProp As UserProperties
Set olAppt = objSubCalFolder.Items.Add
olCode_en_Espacio = False
' I restrict domain for UserProperty with constraint actId =
(ACTIVIDADID)
Set olApptUserProp = olAppt.UserProperties.Find("actId = " &
CStr(ACTIVIDADID))
' From here onwards, then an error occurs due to olApptUserProp value
is equal to nothing
With olApptUserProp
If olApptUserProp.Count > 0 Then olCode_en_Espacio =
olCode_en_Espacio Or True
End With

******************************************************************************************************************************
END
Ken Slovak - [MVP - Outlook]
2010-04-22 14:01:47 UTC
Permalink
Read the help on user properties and on Find/Restrict. You need to add your
user property to the folder fields if you want to use Find or Restrict with
that property. Set the argument for adding the user property to the folder
fields to True when you create the property.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"rventuradiaz" <***@gmail.com> wrote in message news:9871ea59-8ba3-4f04-9e63-***@b23g2000yqn.googlegroups.com...
I am trying to create and add UserProperty in a calendar's subfolder.
Code for creation works fine. However when I develop and debug code
for checking UserProperty, I found nothing was added. ¿Would you help
me to solve this issue, please?

I used the following code for set meeting: BEGIN
***************************************************************************

Dim olAppt As Outlook.AppointmentItem
Set olAppt = objSubCalFolder.Items.Add ' Mod 14-ABR-2010; Establece
el método Add en la Subcarpeta

Dim actField As UserProperty
Set actField = olAppt.UserProperties.Add("actId", olNumber) 'Set
UserProperty


' Set appointment start and end
olAppt.Start = FecIni + CDbl(HorIni)
olAppt.End = FecFin + CDbl(HorIni) / 24# + CDbl(Duracion) / 60# / 24#
Set myRecurrPatt = olAppt.GetRecurrencePattern
myRecurrPatt.RecurrenceType = olRecursDaily
myRecurrPatt.PatternStartDate = FecIni
myRecurrPatt.PatternEndDate = FecFin

' Configurar la información de otra cita...
With olAppt
.Duration = Duracion
.Subject = Asunto
.Body = "Reserva de Aula para actividad: " & Asunto
.Location = "Oficina doméstica"
.ReminderMinutesBeforeStart = 60
.ReminderSet = True

'Is set value for property actId
.UserProperties("actId") = actCode End With

' Guardar la cita...
olAppt.Save
****************************************************************************************************************************
END

Until here, I works fine... However, when I develop and test the code
to check the UserProperty value, then return nothing value, meaning
there is no UserProperties. Here is the code:

Code for check UserProperty: BEGIN
****************************************************************************************

Dim olAppt As Outlook.AppointmentItem
Dim olApptUserProp As UserProperties
Set olAppt = objSubCalFolder.Items.Add
olCode_en_Espacio = False
' I restrict domain for UserProperty with constraint actId =
(ACTIVIDADID)
Set olApptUserProp = olAppt.UserProperties.Find("actId = " &
CStr(ACTIVIDADID))
' From here onwards, then an error occurs due to olApptUserProp value
is equal to nothing
With olApptUserProp
If olApptUserProp.Count > 0 Then olCode_en_Espacio =
olCode_en_Espacio Or True
End With

******************************************************************************************************************************
END
rventuradiaz
2010-04-23 12:44:09 UTC
Permalink
Post by Ken Slovak - [MVP - Outlook]
Read the help on user properties and on Find/Restrict. You need to add your
user property to the folder fields if you want to use Find or Restrict with
that property. Set the argument for adding the user property to the folder
fields to True when you create the property.
--
Ken Slovak
[MVP - Outlook]http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.http://www.slovaktech.com/products.htm
I am trying to create and add UserProperty in a calendar's subfolder.
Code for creation works fine. However when I develop and debug code
for checking UserProperty, I found nothing was added. ¿Would you help
me to solve this issue, please?
I used the following code for set meeting: BEGIN
***************************************************************************
 Dim olAppt As Outlook.AppointmentItem
 Set olAppt = objSubCalFolder.Items.Add ' Mod 14-ABR-2010; Establece
el método Add en la Subcarpeta
 Dim actField As UserProperty
 Set actField = olAppt.UserProperties.Add("actId", olNumber) 'Set
UserProperty
 ' Set appointment start and end
 olAppt.Start = FecIni + CDbl(HorIni)
 olAppt.End = FecFin + CDbl(HorIni) / 24# + CDbl(Duracion) / 60# / 24#
 Set myRecurrPatt = olAppt.GetRecurrencePattern
    myRecurrPatt.RecurrenceType = olRecursDaily
    myRecurrPatt.PatternStartDate = FecIni
    myRecurrPatt.PatternEndDate = FecFin
 ' Configurar la información de  otra cita...
 With olAppt
    .Duration = Duracion
    .Subject = Asunto
    .Body = "Reserva de Aula para actividad: " & Asunto
    .Location = "Oficina doméstica"
    .ReminderMinutesBeforeStart = 60
    .ReminderSet = True
'Is set value for property actId
    .UserProperties("actId") = actCode End With
 ' Guardar la cita...
 olAppt.Save
***************************************************************************­*************************************************
END
Until here, I works fine... However, when I develop and test the code
to check the UserProperty value, then return nothing value, meaning
Code for check UserProperty: BEGIN
***************************************************************************­*************
 Dim olAppt As Outlook.AppointmentItem
 Dim olApptUserProp As UserProperties
 Set olAppt = objSubCalFolder.Items.Add
 olCode_en_Espacio = False
' I restrict domain for UserProperty with constraint actId =
(ACTIVIDADID)
 Set olApptUserProp = olAppt.UserProperties.Find("actId = " &
CStr(ACTIVIDADID))
' From here onwards, then an error occurs due to olApptUserProp value
is equal to nothing
With olApptUserProp
    If olApptUserProp.Count > 0 Then olCode_en_Espacio =
olCode_en_Espacio Or True
End With
***************************************************************************­***************************************************
END
Thank you very much! It works nicely

Loading...