473,466 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Getting WAB Email Addresses: a lame hack

Option Explicit

' requires VBScript to be installed
' (maybe don't give this to your sugnificant other as
' it gets deleted addresses as well as current)
' obvious fixups needed
'1. how get wab file location
' further development
'1. get names too?
' maybe some WABs are encrypted
' mine isn't

Dim RE As Object
Dim Match As Variant
Dim Matches As Variant

Sub WABEMailAddresses(ByVal WABPath As String, IdentityAddress As String)
Dim aAddresses() As String
Dim Address As String
Dim Addresses As String
Dim Buffer As String
Dim FileNumber As Integer

'On Error GoTo WABEMailAddressesErr

FileNumber = FreeFile
Open WABPath For Binary As #FileNumber
Buffer = String(LOF(FileNumber), vbNullChar)
Get #FileNumber, , Buffer
Close #FileNumber
Buffer = StrConv(Buffer, vbFromUnicode)

InitializeRegExp ("[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}")

Set Matches = RE.Execute(Buffer)
For Each Match In Matches
Address = Match.Value
' identity address will show up multiple times
' with numeric prefix
' i'm just going to ignore it
' and repeats too
If InStr(Addresses, Address) = 0 And InStr(Address, IdentityAddress)
= 0 Then
Addresses = Addresses & ";" & Address
End If
Next

If Len(Addresses) > 0 Then
Addresses = Mid$(Addresses, 2)
aAddresses = Split(Addresses, ";")
End If

' this part requires Access >=2k
' but it can be omitted
On Error Resume Next
With WizHook
.Key = 51488399
.SortStringArray aAddresses
End With
On Error GoTo WABEMailAddressesErr

' we now have an sorted (maybe) string of addresses
' delimited with ";"
' we can do whatever we want with them
' I am displaying them in the Immediate window
Addresses = Join(aAddresses, vbNewLine)
Debug.Print Addresses

WABEMailAddressesExit:
ReleaseRegExp
Close
Exit Sub
WABEMailAddressesErr:
With Err
MsgBox .Description, vbCritical, "Error " & .Number
End With
Resume WABEMailAddressesExit
End Sub

Public Sub InitializeRegExp( _
ByRef MaskPattern As String, _
Optional ByRef Globally As Boolean = True, _
Optional ByRef IgnoreCase As Boolean = True)
Set RE = CreateObject("VBScript.RegExp") 'late binding ... Dev would
squirm
With RE
.Global = Globally
.IgnoreCase = IgnoreCase
.Pattern = MaskPattern
End With
End Sub

Public Sub ReleaseRegExp()
Set Matches = Nothing
Set RE = Nothing
End Sub

Sub test()
WABEMailAddresses _
"C:\Documents and Settings\Lyle Fairfield\Application Data\Microsoft
\Address Book\Lyle Fairfield.wab", _
"ly******@hotmail.com"
End Sub

Yeah, I know ... it doesn't work for you ... but it works for me ... and
perhaps someone will be able to solve the enormous problems of cutting
the code and pasting it into a standard module. If you are using Access
97 then of course you already have found or written general functions
that do the same things as Access >=2K Join and Split functions, haven't
you?

--
Lyle Fairfield
Apr 9 '06 #1
1 4246
In response to the overwhelming interest I post a revised version which
finds the location of the WAB file and the names which match the
addresses:

Option Explicit

Private Type MAPIRecip
Reserved As Long
RecipClass As Long
Name As String
Address As String
EIDSize As Long
EntryID As String
End Type

Private Declare Function MAPIResolveName _
Lib "c:\program files\outlook express\msoe.dll" _
Alias "BMAPIResolveName" ( _
ByVal Session As Long, _
ByVal UIParam As Long, _
ByVal UserName As String, _
ByVal Flags As Long, _
ByVal Reserved As Long, _
ByVal Recipient As Long) As Long

Private Declare Function RegOpenKey Lib "advapi32.dll" _
Alias "RegOpenKeyA" _
(ByVal Key As Long, _
ByVal SubKey As String, _
result As Long) _
As Long

Private Declare Function RegQueryValueEx Lib "advapi32.dll" _
Alias "RegQueryValueExA" (ByVal Key As Long, _
ByVal ValueName As String, _
ByVal Reserved As Long, _
ByVal TypeIsAReservedWord As Long, _
Data As String, _
DataLength As Long) _
As Long

Private Declare Function RegCloseKey Lib "advapi32.dll" _
(ByVal Key As Long) _
As Long

Private Const HKEY_LOCAL_MACHINE As Long = &H80000002
Private Const HKEY_CURRENT_USER As Long = &H80000001

' requires VBScript to be installed
' (maybe don't give this to your sugnificant other as
' it gets deleted addresses as well as current)
' further development
'1. get names too?
' maybe some WABs are encrypted
' Win XP has this as registry location of wab file
' may be different in other Win versions
' HKEY_CURRENT_USER\Software\Microsoft\WAB\WAB4\Wab File Name
' mine isn't
' Excludes are list of key words to be excluded from
' list of addresses

Dim RE As Object
Dim Match As Variant
Dim Matches As Variant
' store value for this
' if you want to specify location of WAB file
Dim WabPath As String
Sub WABEMailAddresses(ParamArray Excludes() As Variant)
Dim aAddresses() As String
Dim Address As String
Dim Addresses As String
Dim Buffer As String
Dim FileNumber As Integer
Dim Name As String
Dim Include As Boolean
Dim Iterator As Long

On Error GoTo WABEMailAddressesErr

If Len(WabPath) = 0 Then WabPath = WABLocation

FileNumber = FreeFile
Open WabPath For Binary As #FileNumber
Buffer = String(LOF(FileNumber), vbNullChar)
Get #FileNumber, , Buffer
Close #FileNumber
Buffer = StrConv(Buffer, vbFromUnicode)

InitializeRegExp
("[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}")

Set Matches = RE.Execute(Buffer)
For Each Match In Matches
Address = Match.Value

' identity address probably should be include in Excludes
Include = InStr(Addresses, Address) = 0
If Include Then
For Iterator = LBound(Excludes) To UBound(Excludes)
If InStr(Address, Excludes(Iterator)) <> 0 Then
Include = False
Exit For
End If
Next Iterator
End If

If Include Then
Name = GetNameFromWABAddress(Address)
If Name <> Address Then
Address = "<" & GetNameFromWABAddress(Address) & "> " &
Address
End If
Addresses = Addresses & ";" & Address
End If
Next

If Len(Addresses) > 0 Then
Addresses = Mid$(Addresses, 2)
aAddresses = Split(Addresses, ";")
End If

' this part requires Access >=2k
' but it can be omitted
On Error Resume Next
With WizHook
.Key = 51488399
.SortStringArray aAddresses
End With
On Error GoTo WABEMailAddressesErr

' we now have an sorted (maybe) string of addresses
' delimited with ";"
' we can do whatever we want with them
' I am displaying them in the Immediate window
Addresses = Join(aAddresses, vbNewLine)
Debug.Print Addresses

WABEMailAddressesExit:
ReleaseRegExp
Close
Exit Sub
WABEMailAddressesErr:
With Err
MsgBox .Description, vbCritical, "Error " & .Number
End With
Resume WABEMailAddressesExit
End Sub

Public Sub InitializeRegExp( _
ByRef MaskPattern As String, _
Optional ByRef Globally As Boolean = True, _
Optional ByRef IgnoreCase As Boolean = True)
Set RE = CreateObject("VBScript.RegExp") 'late binding ... Dev
would squirm
With RE
.Global = Globally
.IgnoreCase = IgnoreCase
.Pattern = MaskPattern
End With
End Sub

Public Sub ReleaseRegExp()
Set Matches = Nothing
Set RE = Nothing
End Sub

Public Function WABLocation() As String
Dim Key As Long
Dim KeyName As String
Dim Length As Long
Dim ReturnValue As Long

On Error GoTo WABLocationErr

KeyName = "Software\Microsoft\WAB\WAB4\Wab File Name"
Length = 255
WABLocation = String(255, vbNullChar)

ReturnValue = RegOpenKey(HKEY_CURRENT_USER, KeyName, Key)

If ReturnValue = 0 Then
ReturnValue = RegQueryValueEx(Key, _
"", _
0, _
0, _
ByVal WABLocation, _
Length)
End If

If ReturnValue <> 0 Then Resume WABLocationErr

WABLocationExit:
On Error Resume Next
RegCloseKey Key
Exit Function
WABLocationErr:
MsgBox "WABLocation not retrieved!", vbCritical, "Error!"
WABLocation = 0
Resume WABLocationExit
End Function

Public Function GetNameFromWABAddress(ByVal strAddress As String) As
String
Dim r As MAPIRecip
MAPIResolveName 0, 0, strAddress, 0, 0, VarPtr(r)
GetNameFromWABAddress = StrConv(r.Name, vbUnicode)
End Function

Sub test()
' excludes addresses which include
' lylefair
WABEMailAddresses "lylefair"
End Sub

Apr 9 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Christian Tismer | last post by:
Dear friends. During a conversation with good friends and newly acquired Pythonista, we were discussing Python, what it is in essence, and what it is giving to us. The people were Dinu...
2
by: Hoang | last post by:
anyone know of an algorithm to filter out real email addresses as opposed to computer generated email addresses? I have been going through past email archives in order to find friends email...
0
by: Koncept | last post by:
Sorry for asking, but I give up on this situation. I am a total n00b at Perl and have only used it for about 1 week now. I would really appreciate somebody's help here because I am really feeling...
117
by: Steevo | last post by:
Any suggestions as to the best programs for cloaking email addresses? Many thanks -- Steevo
0
by: Patrick.O.Ige | last post by:
i have a asp.net page and i want to get email addresses from Exchange server. I want the user to get the email addresses from the exchange sever in a textbox and then send the selected user some...
8
by: needhelp | last post by:
Hi there, I really need some help, everything I've tried, all I've found, doesn't seem to work. I have lost an email address which is very important to me. I really need to contact that person...
2
by: rustyc | last post by:
Well, here's my first post in this forum (other than saying 'HI' over in the hi forum ;-) As I said over there: ... for a little side project at home, I'm writing a ham radio web site in...
1
by: Erik Jones | last post by:
So, I was just taking a look at doctest.py and saw this: Then running the module as a script will cause the examples in the docstrings to get executed and verified: python M.py This won't...
2
by: =?Utf-8?B?anVhbg==?= | last post by:
Hello: I have tried for weeks to use LAME in Windows. Can somebody tell me how to do it? I can't add a reference to the project (Visual Basic 2005). Thanks.
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.