Question : Outlook - Store Custom Fields on Folder to Retrieve Later

I am using Outlook 2003 to handle a manuscript-tracking job.  When I receieve email notification of a new manuscript, I want to programmatically parse the message body and store the manuscript number, title, and author so that I can retrieve that info  later and use it in the body of a template message.  I don't have MS Office installed so I'd rather keep that information inside Outlook if possible.  Can I do something like create some user-defined fields on an Outlook object like a folder?  I am already creating a folder that is the manuscript number, so perhaps that object could also contain user-defined fields for the title and author?

I am attaching two procedures.  The first is FileManuscript, which runs when a new manuscript arrives (thanks to BlueDevilFan).  I added the code to add user properties to the folder.  But I can't really tell if that part has worked.  So I created the second procedure, FindProps, which I intend to run by selecting a folder (like "3345") and then click a custom button that runs the procedure.  But FindProps is not even running - I'm getting runtime errors as soon as I get to the objSelection line.  I have a feeling I am mixing VBA and VB Script (based on different internet examples I've been looking at), and now I don't know HOW to proceed.  

I would sure appreciate some help.  Thanks in advance.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
Sub FileManuscript(Item As Outlook.MailItem)
    Dim intPos1 As Integer, _
        intPos2 As Integer, _
        strCaseNumber As String, _
        strEditor As String, _
        objFolder As Object
    Dim customProp1 As Outlook.UserProperty
    Dim customProp2 As Outlook.UserProperty
    Dim customProp3 As Outlook.UserProperty
    intPos1 = InStr(1, Item.Subject, "TRVL-")
    strCaseNumber = Mid(Item.Subject, intPos1 + 5, 4)
    intPos1 = InStr(1, Item.Subject, "editor - ")
    intPos1 = intPos1 + 9
    intPos2 = InStr(1, Item.Subject, ")")
    strEditor = Mid(Item.Subject, intPos1, intPos2 - intPos1)
    Set objFolder = Outlook.Application.Session.GetDefaultFolder(olFolderInbox).Parent.Folders(strEditor)
    Set objFolder = objFolder.Folders.Add(strCaseNumber)
    Item.Move objFolder
    
    Set customProp1 = objFolder.UserProperties.Add(custTitle, "test title")
    Set customProp2 = objFolder.UserProperties.Add(custAuthor, "test author")
    Set customProp3 = objFolder.UserProperties.Add(custMS, strCaseNumber)
    
    Set objFolder = Nothing
End Sub
 
Sub FindProps()
    Dim myApp As Outlook.Application
    Dim myNms As Outlook.NameSpace
    Dim myExplorer As Outlook.Explorer
    Dim myFolder As Outlook.MAPIFolder
    Dim objSelection As Selection
    Dim objProperty As Outlook.UserProperty
    
    Set myApp = CreateObject("Outlook.Application")
    Set myNms = myApp.GetNamespace("MAPI")
    Set myExplorer = myApp.ActiveExplorer
 
    Set objSelection = myApp.myExplorer.Selection
    Select Case objSelection.Count
        Case 0 'NOTHING SeLECTED
            strmsg = "No items were selected"
            MsgBox strmsg, , "No selection"
    Case Else
            Set objProperty = objSelection.UserProperties.Find("custTitle")
            If TypeName(objProperty) = "Nothing" Then
                MsgBox "not found"
            Else
                MsgBox "Title is: " & objProperty.Value
            End If
    End Select
    MsgBox "done"
 
End Sub
Open in New Window Select All

Answer : Outlook - Store Custom Fields on Folder to Retrieve Later

1.  Microsoft must have moved the content.  I'll look for it and if I can find it I'll post the link.
2.  No reason I can think of for it to crash Outlook.  Hopefully that was an aberration.
Random Solutions  
 
programming4us programming4us