folder userproperty - outlook 2000/2002 
Author Message
 folder userproperty - outlook 2000/2002

Hiya

I'm working with user-defined fields.

I know if you create a user-defined field in a mail item
the default behaviour is for this field to also be created
in the folder.

But I am having trouble doing this in the folder I want as
any newly created item seems to exist in the inbox or
drafts folder. If I move my mailitem to a new folder
before adding the userproperties they don't seem to stick
while I'm still holding on to the object reference. It
might work if I move it to the said folder ,set the object
to nothing and then set the object reference again with
the item now in the correct folder.

I also found this script from Sue - but I can't seem to
get it to work, although the script executes quite
happily. objDummy doesn't exist or have any properties. ??

Sub MakeUserPropsInFolder()
    Dim objOL As Outlook.Application
    Dim objNS As Outlook.NameSpace
    Dim objInsp As Outlook.Inspector
    Dim objFld As Outlook.MAPIFolder
    Dim objItem As Object
    Dim objProp As Outlook.UserProperty
    Dim objDummy As Object
    On Error Resume Next

    Set objOL = CreateObject("Outlook.Application")
    Set objNS = objOL.GetNamespace("MAPI")
    Set objFld = objNS.PickFolder
    If Not objFld Is Nothing Then
        Set objInsp = Application.ActiveInspector
        If Not objInsp Is Nothing Then

            Set objItem = objInsp.CurrentItem

            Set objDummy = objFld.Items.Add
            For Each objProp In objItem.UserProperties
                MsgBox objProp.Name
                objDummy.UserProperties.Add objProp.Name,
objProp.Type
                If Err Then
                    Debug.Print Err, Err.Description
                    Err.Clear
                End If
            Next
        End If
    End If

    Set objDummy = Nothing
    Set objItem = Nothing
    Set objProp = Nothing
    Set objFld = Nothing
    Set objInsp = Nothing
    Set objNS = Nothing
    Set objOL = Nothing
End Sub

Also the object browser model doesn't show any
userproperty values for MAPIfolders.

I was wondering is there any code based way of creating
these user properties in a folder? I ask as I'm using

Set myMailItem = myDestFolder.Items.Find(querystring)
using the userdefined fields in the query string

cheers for any help

Nomit



Fri, 04 Nov 2005 21:43:07 GMT  
 folder userproperty - outlook 2000/2002
Don't use a MailItem to add UserPropeties. Use a PostItem instead.
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
     Microsoft Outlook Programming: Jumpstart
     for Administrators, Power Users, and Developers
     http://www.slipstick.com/books/jumpstart.htm
Quote:

> Hiya

> I'm working with user-defined fields.

> I know if you create a user-defined field in a mail item
> the default behaviour is for this field to also be created
> in the folder.

> But I am having trouble doing this in the folder I want as
> any newly created item seems to exist in the inbox or
> drafts folder. If I move my mailitem to a new folder
> before adding the userproperties they don't seem to stick
> while I'm still holding on to the object reference. It
> might work if I move it to the said folder ,set the object
> to nothing and then set the object reference again with
> the item now in the correct folder.

> I also found this script from Sue - but I can't seem to
> get it to work, although the script executes quite
> happily. objDummy doesn't exist or have any properties. ??

> Sub MakeUserPropsInFolder()
>     Dim objOL As Outlook.Application
>     Dim objNS As Outlook.NameSpace
>     Dim objInsp As Outlook.Inspector
>     Dim objFld As Outlook.MAPIFolder
>     Dim objItem As Object
>     Dim objProp As Outlook.UserProperty
>     Dim objDummy As Object
>     On Error Resume Next

>     Set objOL = CreateObject("Outlook.Application")
>     Set objNS = objOL.GetNamespace("MAPI")
>     Set objFld = objNS.PickFolder
>     If Not objFld Is Nothing Then
>         Set objInsp = Application.ActiveInspector
>         If Not objInsp Is Nothing Then

>             Set objItem = objInsp.CurrentItem

>             Set objDummy = objFld.Items.Add
>             For Each objProp In objItem.UserProperties
>                 MsgBox objProp.Name
>                 objDummy.UserProperties.Add objProp.Name,
> objProp.Type
>                 If Err Then
>                     Debug.Print Err, Err.Description
>                     Err.Clear
>                 End If
>             Next
>         End If
>     End If

>     Set objDummy = Nothing
>     Set objItem = Nothing
>     Set objProp = Nothing
>     Set objFld = Nothing
>     Set objInsp = Nothing
>     Set objNS = Nothing
>     Set objOL = Nothing
> End Sub

> Also the object browser model doesn't show any
> userproperty values for MAPIfolders.

> I was wondering is there any code based way of creating
> these user properties in a folder? I ask as I'm using

> Set myMailItem = myDestFolder.Items.Find(querystring)
> using the userdefined fields in the query string

> cheers for any help

> Nomit



Mon, 07 Nov 2005 06:39:54 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Mosher Outlook 2000 Code wont run in Outlook 2002

2. Outlook Plugin - 2000 and 2002?

3. Outlook 2000 & 2002

4. Programming with Outlook 2002 / Windows 2000 possible?

5. Always BCC in Outlook 2000/2002/XP

6. programmatically creating, modifying, or deleting Exchange 2000-based rules using VBA through Outlook 2002

7. GUI extension for Outlook 2000/2002 !

8. Project 2002 and Outlook 2000

9. Experts: Outlook 2000 / 2002 and VBScript

10. VB, OUTLOOK 2002 & 2000 and CRYSTAL REPORT

11. Change folder by start of Outlook 2002

12. Outlook 2002 - Problems Synchronizing Multiple Folders

 

 
Powered by phpBB® Forum Software