Madmarlin
asked on
Serching The Outlook Address Book Through VB
Hello experts,
Im working on a project which involves automating an email.
The users address book is very large and therefore can really wait for the full address book to load.
Is there a way of searching the addressbook content by certain criteria??
My code is as follows (currently loads all addressbook enteries, but say I wanted to list all enteries with the word 'Chris' in the name field)
Private Sub Command1_Click()
Dim oRecipiant As ListItem
Dim myAddressList As AddressList
Dim AddressEntry As AddressEntry
'Clear Address Book
lvAddressBook.ListItems.Cl ear
lvAddressBook.ColumnHeader s.Clear
lvAddressBook.View = lvwReport
'Add Columns
With lvAddressBook.ColumnHeader s
.Add , , "Name"
'.Add , , "Other Field"
End With
Set myAddressList = Application.Session.Addres sLists("Gl obal Address List")
For Each AddressEntry In myAddressList.AddressEntri es
Set oRecipiant = lvAddressBook.ListItems.Ad d(, , AddressEntry.Name)
Next
End Sub
Im working on a project which involves automating an email.
The users address book is very large and therefore can really wait for the full address book to load.
Is there a way of searching the addressbook content by certain criteria??
My code is as follows (currently loads all addressbook enteries, but say I wanted to list all enteries with the word 'Chris' in the name field)
Private Sub Command1_Click()
Dim oRecipiant As ListItem
Dim myAddressList As AddressList
Dim AddressEntry As AddressEntry
'Clear Address Book
lvAddressBook.ListItems.Cl
lvAddressBook.ColumnHeader
lvAddressBook.View = lvwReport
'Add Columns
With lvAddressBook.ColumnHeader
.Add , , "Name"
'.Add , , "Other Field"
End With
Set myAddressList = Application.Session.Addres
For Each AddressEntry In myAddressList.AddressEntri
Set oRecipiant = lvAddressBook.ListItems.Ad
Next
End Sub
or try use Instr function, like:
Private Sub Command1_Click()
Dim oRecipiant As ListItem
Dim myAddressList As AddressList
Dim AddressEntry As AddressEntry
'Clear Address Book
lvAddressBook.ListItems.Cl ear
lvAddressBook.ColumnHeader s.Clear
lvAddressBook.View = lvwReport
'Add Columns
With lvAddressBook.ColumnHeader s
.Add , , "Name"
'.Add , , "Other Field"
End With
Set myAddressList = Application.Session.Addres sLists("Gl obal Address List")
For Each AddressEntry In myAddressList.AddressEntri es
If Instr(1,lcase$(AddressEntr y.Name), lcase$(sSearchName )) > 0 then
Set oRecipiant = lvAddressBook.ListItems.Ad d(, , AddressEntry.Name)
End If
Next
End Sub
Private Sub Command1_Click()
Dim oRecipiant As ListItem
Dim myAddressList As AddressList
Dim AddressEntry As AddressEntry
'Clear Address Book
lvAddressBook.ListItems.Cl
lvAddressBook.ColumnHeader
lvAddressBook.View = lvwReport
'Add Columns
With lvAddressBook.ColumnHeader
.Add , , "Name"
'.Add , , "Other Field"
End With
Set myAddressList = Application.Session.Addres
For Each AddressEntry In myAddressList.AddressEntri
If Instr(1,lcase$(AddressEntr
Set oRecipiant = lvAddressBook.ListItems.Ad
End If
Next
End Sub
In either case the code is going to have to read the entire address book, whether it populates the LV control with all the names or a subset of the names. If you aren't tied to using the Outlook Object Model though, then you could use CDO which has a filtering capability which'd save having to read the entire address list to find just those names that match.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdo/html/_olemsg_addressentryfilter_object.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdo/html/_olemsg_addressentryfilter_object.asp
ASKER
The comments from BlueDevilFan are correct, my problem is the number of enteries in the addresslist is ridiculously large therefore I cant loop through each one indiviually.
I am also trying to run the code the BlueDevilFan sent me without success.
I am running VB6 and the version of the CDO.DLL on my platform is 1.21 and not 1.1 so im not sure if somthing has changed, and cant seem to find any refernce to a change anywhere.
SO if proven source could be provided I am prepared to up the points.
Cheers Madmarlin
I am also trying to run the code the BlueDevilFan sent me without success.
I am running VB6 and the version of the CDO.DLL on my platform is 1.21 and not 1.1 so im not sure if somthing has changed, and cant seem to find any refernce to a change anywhere.
SO if proven source could be provided I am prepared to up the points.
Cheers Madmarlin
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great work BlueDevilFan maybe you can help with this one, its similar and worth 400 points if quick
https://www.experts-exchange.com/questions/21158007/Obtaining-The-Mailbox-Size-Limit.html
Madmarlin
Hi, Madmarlin.
Thanks. I saw your other question last night and spent a couple of hours researching the issue. I can't find anything that reports the quota limits for 5.5. The best I can offer is code that'll calculate mailbox size for 5.5 (although I can't verify that it works under 5.5 since I don't have access to a 5.5 server anymore). If you know the quota limts, and if they are consistent (i.e. each user doesn't have a different limit), then you could caluclate the mailbox size, compare it to the limit, and take action as needed based on that comparison.
Thanks. I saw your other question last night and spent a couple of hours researching the issue. I can't find anything that reports the quota limits for 5.5. The best I can offer is code that'll calculate mailbox size for 5.5 (although I can't verify that it works under 5.5 since I don't have access to a 5.5 server anymore). If you know the quota limts, and if they are consistent (i.e. each user doesn't have a different limit), then you could caluclate the mailbox size, compare it to the limit, and take action as needed based on that comparison.
ASKER
ha ha so i didnt only waste hours myself yesterday I wasted your time aswell, im very sorry.
Yes I do believe that the limit is standard through my user base, so if you know how to check the mailbox size then I uess that would surfice.
On a persoanl note I would just like to say thankyou for you help on both this and the previous problem.
Cheers Madmarlin... ;?)
No need to be sorry. I enjoy the challenges I find here in EE. It keeps the mind sharp.
Ok, I'll post the code for getting the mailbox sizes shortly. I'll post it to the other question.
You're very welcome.
Ok, I'll post the code for getting the mailbox sizes shortly. I'll post it to the other question.
You're very welcome.
ASKER
Message for BlueDevilFan...
Did you ever find the code for the other question. (see previosu comments?)
Cheers Chris
Did you ever find the code for the other question. (see previosu comments?)
Cheers Chris
Chris,
I posted the best information I have in the other question.
-- BDF
I posted the best information I have in the other question.
-- BDF
Dim sSearchName As String
sSearchName = "*chris*"
...
For Each AddressEntry In myAddressList.AddressEntri
If Lcase$(AddressEntry.Name) like sSearchName then
Set oRecipiant = lvAddressBook.ListItems.Ad
End If
Next
...