View Single Post
  #5  
Old June 23rd 06, 02:49 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Copy from public contacts to local folder

This may be your problem:

Set myNewFolder = mypubContact.CopyTo(myContactsFolder)

As the Help topic for the CopyTo method states:

Copies the current folder in its entirety to the destination folder. Returns a MAPIFolder object that represents the new copy.

In other words, that statement creates a replica of the public folder as a new sub folder under the mypubContact folder that contains a replica of the Contacts folder from your mailbox. Is that what you want? If not, then you need to iterate the items in myPubContact using a For Each ... Next loop and copy each item to the target folder (myContactsFolder), e.g:

For Each itm in mypubContact.Items
Set copy = itm.Copy
copy.Move myContactsFolder
Next

now the problem is... since i delete
the old contact stored in the BUSINESS CONTACT folder.....these old items
are stored to my deleted item folder and i cannot delete it correctly ( it's
the commented part of the script )


'Set mytrash = myNameSpace.GetDefaultFolder(olFolderDeletedItems)
'Set mytrashcont = mytrash.Folders("BUSINESS CONTACT")
'mytrashcont.Delete

What happens when you run that code?
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Cecco" wrote in message ...
I've created a macro for this purpose...


************************************************** ************************

Sub Copia()

Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myContactsFolder As Outlook.MAPIFolder
Dim myNewFolder As Outlook.MAPIFolder
Dim mytrashfolder As Outlook.MAPIFolder
Dim myrashcont As Outlook.MAPIFolder

Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myContactsFolder = myNameSpace.GetDefaultFolder(olFolderContacts)
Set mysync = myContactsFolder.Folders.Item("BUSINESS CONTACT")
mysync.Delete

Set mypubContact =
myNameSpace.GetDefaultFolder(olPublicFoldersAllPub licFolders).Folders.Item("BUSINESS
CONTACT")
Set myNewFolder = mypubContact.CopyTo(myContactsFolder)

'Sleep 2000
'Set mytrash = myNameSpace.GetDefaultFolder(olFolderDeletedItems)
'Set mytrashcont = mytrash.Folders("BUSINESS CONTACT")
'mytrashcont.Delete

End Sub
************************************************** ************************

With this macro the contacts are copied to a subfolder called BUSINESS
CONTACT under my contacts folder.....now the problem is... since i delete
the old contact stored in the BUSINESS CONTACT folder.....these old items
are stored to my deleted item folder and i cannot delete it correctly ( it's
the commented part of the script )






"Cecco" ha scritto nel messaggio
...
I've tried with so many differente scripts, i think it better to create a
brand new one.

i dont know exactly how to make in vbs this tasks.


1. the script will get the public folder thath contains the contact.
2. for each contact in this folder
2.1 copy each contact to local folder

any idea on how to accomplish this?


Regards

Stefano






"Sue Mosher [MVP-Outlook]" ha scritto nel
messaggio ...
What in particular didn't work? If you already have it 90% done, there's
no point in starting over.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Cecco" wrote in message
...
Hello

I need a Vbscript that copy all the contacts from a specified public
folder
(public folder\all public folder\custom contact) to a local folder.

I've tried with many different script but none of them works.....i dont
know
how to get it works...



Thanks in advance for any help.


Stefano






Ads