Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OL Address Book 2

Status
Not open for further replies.

ClulessChris

IS-IT--Management
Jan 27, 2003
890
0
0
GB
I'd would like to check through a users Personal address book and if a specifiyed recipient is absent add them in? Can you help?

Also I have a custom form published to a public folder, is it possible to launch this via code?

P.S. We're running MS Outlook 98.

Everybody body is somebodys Nutter.
 
Personal address books are in .pst files, normally on the users hard drive so doing it centrally will be problematic.

Unless you meant their contact folder?
 
rdroske

It's the Personal address book (in a *.PAB file) that I'm after. however the user would be logged on and run the program them self's, I was looking for a method to connect via Outlook. Any ideas?

Everybody body is somebodys Nutter.
 
Code:
Dim objApp As Outlook.Application
Dim objNS As Outlook.Namespace
Dim objAddrList As Outlook.AddressList
Dim objAddrEntries As Outlook.AddressEntry
Dim objAddrEntry As Outlook.AddressEntry
Dim blnExists As Boolean

Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objAddrList = objNS.AddressLists("Personal Address Book")
Set objAddrEntries = objAddrList.AddressEntries
Set objAddrEntry = objAddrEntries.GetFirst
Do Until objAddrEntry Is Nothing
 If objAddrEntry.DisplayType = olUser Then
  If objAddrEntry.Name = "Joe Bloggs" Then
   'Recipient already in address book
   blnExists = True
   Exit Do
  End If
 End If
 Set objAddrEntry = objAddrEntries.GetNext
Loop

If Not blnExists Then
 'Recipient not found, add it
 Set objAddrEntry = objAddrEntries.Add( _
 "User", "Joe Bloggs", "joe@nowhere.com"
End If

Set objAddrEntry = Nothing
Set objAddrEntries = Nothing
Set objAddrList = Nothing
Set objNS = Nothing
Set objApp = Nothing

Paul Bent
Northwind IT Systems
 
Yep that will do it then, sorry about the .pst typo. .pab is correct.
 
PaulBent
You're a Star...So here's one from me. Many thanks

Everybody body is somebodys Nutter.
 
PaulBent
Do you have any ideas on launching a custom form from a public folder? Is there a function for this?
CreateItemFromTemplate doesn't seem to meet the bill.

Everybody body is somebodys Nutter.
 
If you open the public folder in an Outlook Explorer, you should be able to launch the form from the menu. Menu items are exposed through the CommandBars collection.

Paul Bent
Northwind IT Systems
 
Paul
Thanks once again.

Everybody body is somebodys Nutter.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top