PC Review Forums Newsgroups Microsoft Outlook Microsoft Outlook Program Addins Extracting phone nr from mail recipient?

Reply

Extracting phone nr from mail recipient?

 
Thread Tools Rate Thread
Old 24-06-2004, 10:54 AM   #1
Mats-Lennart Hansson
Guest
 
Posts: n/a
Default Extracting phone nr from mail recipient?


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


  Reply With Quote
Old 24-06-2004, 02:28 PM   #2
Ken Slovak - [MVP - Outlook]
Guest
 
Posts: n/a
Default Re: Extracting phone nr from mail recipient?

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.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Mats-Lennart Hansson" <ap_skallen@hotmail.com> wrote in message
news:uXF4SFdWEHA.4064@TK2MSFTNGP11.phx.gbl...
> 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
>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off