Adding Item or User Properties to a received MailItem

  • Thread starter Thread starter Andrew Caplinger
  • Start date Start date
A

Andrew Caplinger

I've modified the MicroEye ItemsCB sample code and am implementing a To
Be Filed button, which moves the current received mailitem(s) to a hard-
coded root folder. I've got everything working with the buttons and
commandbars showing up correctly on both Explorer and Inspector objects.

I'd like to add a custom property to each mailitem after moving it into
the To Be Filed folder, and fill it with a note that the user enters, to
help with later filing of the message. Then I want that user-added note
to be visible with a custom view in the To Be Filed folder.

When I do either itm.UserProperties.Add(..) or itm.ItemProperties.Add
(..), I don't get an error. However, if I check the itm.Saved property
immediately aftwards, it claims the item hasn't been modified. Upon
looking at the moved item properties, the date modified is not changed,
and the custom folder view doesn't show the property either.

So next I tried getting an inspector to the mailitem, then
programmatically pressing the Edit Message button (ID:5604), then adding
the property, then saving and closing the inspector. No dice.

Two questions: What is the difference between UserProperties and
ItemProperties? Why can't I successfully get either to appear to work on
received messages?

Thanks in advance.
-Andrew

Here's the code:

Private Sub MoveToFiled(itm As Outlook.MailItem, strNote As String)
On Error Resume Next
Dim prpNote As UserProperty
Dim fld As MAPIFolder
Dim insp As Inspector
Dim CBC As CommandBarControl
Set fld = GetToBeFiledFolder()
itm.Move fld
Set insp = itm.GetInspector
Set CBC = insp.CommandBars.FindControl(ID:=5604)
CBC.Execute
Set CBC = Nothing
Set prpNote = itm.UserProperties("FilingNote")
If TypeName(prpNote) = "Nothing" Then
Set prpNote = itm.UserProperties.Add("FilingNote", olText, True)
End If
prpNote.Value = strNote

If itm.Saved Then
MsgBox "adding UserProperty didn't modify item."
End If
itm.Save
insp.Close olSave
Set insp = Nothing
Set fld = Nothing
Set prpNote = Nothing
End Sub
 
Well, that explains it! Thanks so much for the quick response, Sue! I
ended up using the BillingInformation property. I never thought to look
for those properties because they seem oddly placed.

BTW, While auto-creating the root To Be Filed folder, I'm creating a
custom view for that folder showing the BillingInformation field, renamed
Filing Note. I used a debug.print line in the VBA portion to extract the
View.XML property, then pasted the resulting 105 lines of text into the
module as a huge concatenated string. It looks pretty kludgey, but it
works great.

Thanks again!

-Andrew
 
Back
Top