How do I add a contact to a public folder programatically 
Author Message
 How do I add a contact to a public folder programatically

I have a public folder called 'Office' which everybody has
access to.  I want the ability from VB or VBA to add
contact to this folder automatically using code... any
ideas?

I know how to do it with an ordinary folder...

Thanks

James Burns



Tue, 20 Apr 2004 03:57:07 GMT  
 How do I add a contact to a public folder programatically
You would need to use code to set the folder object.  Use the following
function call and function.

This is for VB.  You'd have to revise it for VBScript behind an Outlook
form.  VBScript does not support declaring as a variable type.  For VBA
inside Outlook 2000 or 2002 you can eliminate the Outlook from the
declarations.

Set objFolder = OpenMAPIFolder("\Public Folders\All Public
Folders\FolderName")

Public Function OpenMAPIFolder(FolderPath As String) As MAPIFolder
    Dim aFolders() As String
    Dim fldr As Outlook.MAPIFolder
    Dim i As Long
    Dim objNS As Outlook.NameSpace
    Dim objApp As Outlook.Application

    On Error GoTo ErrorExit

    aFolders() = Split(FolderPath, "\")

    'get the Outlook objects

    Set objApp = CreateObject("Outlook.Application")
    Set objNS = objApp.GetNamespace("MAPI")

    'set the root folder
    Set fldr = objNS.Folders(aFolders(0))

    'loop through the array to get the subfolders
    'loop is skipped when there is only one element in the array
    For i = 1 To UBound(aFolders)
        Set fldr = fldr.Folders(aFolders(i))
    Next

    Set GetOLFolder = fldr

ErrorExit:
    'dereference objects
    Set objNS = Nothing
    Set objApp = Nothing
End Function

--
Patricia Cardoza
~Outlook MVP~
www.cardozasolutions.com

~Please post all replies to the newsgroups~


Quote:
> I have a public folder called 'Office' which everybody has
> access to.  I want the ability from VB or VBA to add
> contact to this folder automatically using code... any
> ideas?

> I know how to do it with an ordinary folder...

> Thanks

> James Burns



Wed, 21 Apr 2004 12:38:02 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Adding/Deleting Contacts in Public Folders

2. Public Folder Contact folders.

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

4. Add contact information to folder other than default folder

5. Filtering public folder view programatically

6. Programatically export contacts folder to pst file

7. Programatically post to a specific public folder

8. Resolve Contact to Public Folder

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

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

11. Create New Contact in Public Folder

12. Referring to Items in Public (Contacts) Folder

 

 
Powered by phpBB® Forum Software