SvenBlomme
07-01-2015, 06:27 AM
Hi,
I'm trying to find a way to add a user defined property to incoming email and to display this in a user defined field.
The idea is that, for every incoming message, I want to check every recipient to determine who is the first recipient (either in TO or in CC) from a specific domain (my company), and to display this person's name or email address in an additinoal column (by adding this name or address as a user defined property to the incoming message). When I test the below code I don't get any error messages but the user defined field is not populated.
Here is what I have so far;
Sub Filer(Item As Outlook.MailItem)
Dim olkUDP2 As Outlook.UserProperty
Dim recip As Outlook.Recipient
Dim udp2value As String
Dim i As Long
If Item.Class = olMail Then
For i = 1 To Item.Recipients.Count
Set recip = Item.Recipients.Item(i)
If InStr(recip.Address, "mycompanydomain") > 0 Then
Set olkUDP2 = Item.UserProperties.Add("Filer", olText, True)
olkUDP2 = recip.Address
Exit For
End If
Next i
End Sub
Can anybody tell me what I am doing wrong?
I'm trying to find a way to add a user defined property to incoming email and to display this in a user defined field.
The idea is that, for every incoming message, I want to check every recipient to determine who is the first recipient (either in TO or in CC) from a specific domain (my company), and to display this person's name or email address in an additinoal column (by adding this name or address as a user defined property to the incoming message). When I test the below code I don't get any error messages but the user defined field is not populated.
Here is what I have so far;
Sub Filer(Item As Outlook.MailItem)
Dim olkUDP2 As Outlook.UserProperty
Dim recip As Outlook.Recipient
Dim udp2value As String
Dim i As Long
If Item.Class = olMail Then
For i = 1 To Item.Recipients.Count
Set recip = Item.Recipients.Item(i)
If InStr(recip.Address, "mycompanydomain") > 0 Then
Set olkUDP2 = Item.UserProperties.Add("Filer", olText, True)
olkUDP2 = recip.Address
Exit For
End If
Next i
End Sub
Can anybody tell me what I am doing wrong?