Resolve Contact to Public Folder 
Author Message
 Resolve Contact to Public Folder

I'm writing a VBA application that adds a member to a distribution list for
a conact.  Both the DL and contact are in a public folder.  In Outlook 2000,
I have set the "Show this folder as an e-mail Address Book" on.  When using
the resolveall method, the name is not resolved to the contact in the public
folder.  If I copy the the contact to my conacts folder, resolveall works.
Should the application resolve addressess to contact in a public folder?  If
so, how would I do it.  Below is the code I'm using.  Thanks for the help.

== Code ==

Sub UpdateDLAffilEmail()

Dim golApp As Outlook.Application
Dim gnspNameSpace As Outlook.NameSpace
Dim fldFolder As Outlook.MAPIFolder
Dim sF1, sF2, sF3, sF4 As String
Dim objItems As Outlook.Items
Dim objDL As Outlook.DistListItem
Dim objContact As Outlook.ContactItem
Dim objMailItem As Outlook.MailItem
Dim objRec As Outlook.Recipients
Dim objrec1 As Outlook.Recipient

Set golApp = New Outlook.Application
Set gnspNameSpace = golApp.GetNamespace("MAPI")

'get distination public folder object
sF1 = "Public Folders"
sF2 = "All Public Folders"
sF3 = "Distribution Lists"
sF4 = "Credit Unions"

Set fldFolder =
gnspNameSpace.Folders(sF1).Folders(sF2).Folders(sF3).Folders(sF4)
Set objItems = fldFolder.Items

Set objMailItem = golApp.CreateItem(olMailItem)

Set objDL = fldFolder.Items("Affiliate E-Mail")

Set objRec = objMailItem.Recipients

Set objContact = objItems.Find("[Customer ID] = '136'")

objRec.Add objContact.Email1DisplayName

If Not objRec.ResolveAll Then
    For Each objrec1 In objRec
        If Not objrec1.Resolved Then
            MsgBox objrec1.Name
        End If
    Next
End If

objDL.AddMembers objRec

objDL.Save

End Sub



Mon, 22 Mar 2004 03:30:51 GMT  
 Resolve Contact to Public Folder
"Show this folder as an e-mail Address Book" only does what is says, nothing
more. If you need to make sure that a particular folder is used in the name
resolution, open the address book (Tools | Address Book), go to Tools | Options,
click "Add".

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool



Quote:
> I'm writing a VBA application that adds a member to a distribution list for
> a conact.  Both the DL and contact are in a public folder.  In Outlook 2000,
> I have set the "Show this folder as an e-mail Address Book" on.  When using
> the resolveall method, the name is not resolved to the contact in the public
> folder.  If I copy the the contact to my conacts folder, resolveall works.
> Should the application resolve addressess to contact in a public folder?  If
> so, how would I do it.  Below is the code I'm using.  Thanks for the help.

> == Code ==

> Sub UpdateDLAffilEmail()

> Dim golApp As Outlook.Application
> Dim gnspNameSpace As Outlook.NameSpace
> Dim fldFolder As Outlook.MAPIFolder
> Dim sF1, sF2, sF3, sF4 As String
> Dim objItems As Outlook.Items
> Dim objDL As Outlook.DistListItem
> Dim objContact As Outlook.ContactItem
> Dim objMailItem As Outlook.MailItem
> Dim objRec As Outlook.Recipients
> Dim objrec1 As Outlook.Recipient

> Set golApp = New Outlook.Application
> Set gnspNameSpace = golApp.GetNamespace("MAPI")

> 'get distination public folder object
> sF1 = "Public Folders"
> sF2 = "All Public Folders"
> sF3 = "Distribution Lists"
> sF4 = "Credit Unions"

> Set fldFolder =
> gnspNameSpace.Folders(sF1).Folders(sF2).Folders(sF3).Folders(sF4)
> Set objItems = fldFolder.Items

> Set objMailItem = golApp.CreateItem(olMailItem)

> Set objDL = fldFolder.Items("Affiliate E-Mail")

> Set objRec = objMailItem.Recipients

> Set objContact = objItems.Find("[Customer ID] = '136'")

> objRec.Add objContact.Email1DisplayName

> If Not objRec.ResolveAll Then
>     For Each objrec1 In objRec
>         If Not objrec1.Resolved Then
>             MsgBox objrec1.Name
>         End If
>     Next
> End If

> objDL.AddMembers objRec

> objDL.Save

> End Sub



Mon, 22 Mar 2004 08:17:26 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Resolve to contact in public folder

2. Public Folder Contact folders.

3. Syncronize in programmatic way, the folder Contact with the public folder

4. How do I add a contact to a public folder programatically

5. Need sample code for read public folder contact into access

6. Enable a Public folder (contacts) for Outlook address Book

7. Create New Contact in Public Folder

8. Referring to Items in Public (Contacts) Folder

9. Synchronizing/exporting contacts into Public Folder

10. Creating Contacts in a Public Folder

11. Error copying a public Contact folder within Outlook 2000 SR1

12. Public Contacts Folder

 

 
Powered by phpBB® Forum Software