Extracting phone nr from mail recipient?

  • Thread starter Mats-Lennart Hansson
  • Start date
M

Mats-Lennart Hansson

I'm using the redemption object. When a new mail arrives, I want to extract
the phone nr from the sender. This is done by looking in the address lists
for this user.

Is there an easier way to do this? This will be a slow solution with large
address lists.

Thanks,
Mats-Lennart

My code:

Private Sub redUtils_NewMail(ByVal Item As Object)
Select Case Item.MessageClass
Case "IPM.Note"
gsMobNr = GetMobileNumber(Item)

Case Else
rTracing.TraceLog "Info", "redUtils_NewMail", "Non supported
message type."
End Select
End Sub

Private Function GetMobileNumber(ByRef olMailItem As Object) As String

On Error GoTo ErrHandler

Dim sAddress As String
Dim rSafeMailItem As New Redemption.SafeMailItem
Dim i As Integer, ii As Integer

rSafeMailItem.Item = olMailItem

sAddress = rSafeMailItem.SenderEmailAddress

For i = 0 To rAddressLists.Count
Set rAddressEntries = rAddressLists(i).AddressEntries
For ii = 0 To rAddressEntries.Count
If (UCase(rAddressEntries(ii).Address) = UCase(sAddress))
Then
GetMobileNumber = rAddressEntries(ii).Fields(&H3A1C001E)
Exit Function
End If
Next ii
Next i

Exit Function
ErrHandler:
GetMobileNumber = "Unknown"
End Function
 
K

Ken Slovak - [MVP - Outlook]

With Redemption you could set up a MAPITable filter on each AddressEntries
collection to retrieve an AddressEntry from that collection. The filter
would be based on the recipient name, which is the only type of
AddressEntries filter you can use. However that would be pretty fast since
you wouldn't need those nested loops. You could just check to see if each
collection returned any results. See Dmitry's example for an AddressEntries
filter on his Web site.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top