A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Copy from public contacts to local folder



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 22nd 06, 03:51 PM posted to microsoft.public.outlook.program_vba
Cecco
external usenet poster
 
Posts: 3
Default Copy from public contacts to local folder

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
  #2  
Old June 22nd 06, 04:32 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

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


  #3  
Old June 23rd 06, 08:42 AM posted to microsoft.public.outlook.program_vba
Cecco
external usenet poster
 
Posts: 3
Default Copy from public contacts to local folder

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




  #4  
Old June 23rd 06, 11:17 AM posted to microsoft.public.outlook.program_vba
Cecco
external usenet poster
 
Posts: 3
Default Copy from public contacts to local folder

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






  #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






 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy single message to public folder MFH Outlook and VBA 3 June 9th 06 08:09 AM
Contact in public folder defaults to local contact folder Alison Outlook - Using Contacts 8 May 30th 06 04:32 AM
How i export/copy/move messages in a public folder outlook 2003? Olatunde R. Adeniran Outlook - Using Contacts 1 May 3rd 06 06:51 PM
Copy of Outlook 2002 appointment sent to Public Folder calendar gets to another calendar QH Outlook - Calandaring 1 February 2nd 06 02:45 PM
Copy useful news to local folder kei Outlook Express 3 January 21st 06 12:37 AM


All times are GMT +1. The time now is 05:22 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.