J
James Klimek
Hi - When the a recipient is added to the To field of the
mail item form, I need to get the first "TO" recipient
item listed and then retrieve the contact item.
For some reason, I can't seem to get the contact. I want
to avoid iterating over the contacts folder comparing
each contact to the recipient.
I have the following VBA code in my my form:
Sub Item_PropertyChange( ByVal Name )
If (Name = "To")Then
LookupContact
End If
End Sub
Sub LookupContact()
' Get the first recipient in the list - will add more
' code here later to make sure its type is TO
Dim oRecipient
Set oRecipient = Item.Recipients(1)
Dim sRecipientEID
sRecipientEID = oRecipient.EntryID
Dim oNS
Set oNS = Item.Application.GetNamespace("MAPI")
Dim oContactsFolder
Set oContactsFolder = oNS.GetDefaultFolder(10)
Dim sStoreID
sStoreID = oContactsFolder.StoreID
Dim oContact
Set oContact = oNS.GetItemFromID(sRecipientID, sStoreID)
If (Not oContact Is Nothing) Then
' Do something useful with my contact
Else
msgbox "Contact Found!"
End If
End Sub
Anyone have a thoughts or suggestions?
Thanks!
- Jim
mail item form, I need to get the first "TO" recipient
item listed and then retrieve the contact item.
For some reason, I can't seem to get the contact. I want
to avoid iterating over the contacts folder comparing
each contact to the recipient.
I have the following VBA code in my my form:
Sub Item_PropertyChange( ByVal Name )
If (Name = "To")Then
LookupContact
End If
End Sub
Sub LookupContact()
' Get the first recipient in the list - will add more
' code here later to make sure its type is TO
Dim oRecipient
Set oRecipient = Item.Recipients(1)
Dim sRecipientEID
sRecipientEID = oRecipient.EntryID
Dim oNS
Set oNS = Item.Application.GetNamespace("MAPI")
Dim oContactsFolder
Set oContactsFolder = oNS.GetDefaultFolder(10)
Dim sStoreID
sStoreID = oContactsFolder.StoreID
Dim oContact
Set oContact = oNS.GetItemFromID(sRecipientID, sStoreID)
If (Not oContact Is Nothing) Then
' Do something useful with my contact
Else
msgbox "Contact Found!"
End If
End Sub
Anyone have a thoughts or suggestions?
Thanks!
- Jim