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.
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)
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
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"
Set objProperty = objSelection.UserProperties.Find("custTitle")
If TypeName(objProperty) = "Nothing" Then
MsgBox "not found"
MsgBox "Title is: " & objProperty.Value