|
-
Aug 31st, 2005, 03:58 AM
#1
Thread Starter
New Member
Outlook: Copy a Task to another Task Folder
Hi!
I've been trying to find an answer to my problem for a while and still have no clue about it... Perhaps anybody here would be able to help me??
Information: I work with Outlook 2003 and Public ShareFolder v1.2
To make it simple Public SF is an application allowing all Outlook "clients" of a small network to acess the Outlook server's .pst files...
My problem:
From my Outlook "client" I can manually copy tasks from the client's task folder to the server's task folder.
I'd would like to do it automatically with a macro... But i'm not sure it's possible
thanks
-
Aug 31st, 2005, 10:58 AM
#2
Re: Outlook: Copy a Task to another Task Folder
Welcome to the Forums.
You would need to access the Item in the source MAPI folder and then create a reference to the destination MAPI folder. Then just invoke the .Copy method on each item in the source folder in a loop. This program "Public ShareFolder v1.2" create several pst files or a single one?
This will work (maybe an error since I typed it into the reply box ) but if the public destination folder is in another pst file then it may require some extra code.
VB Code:
dim oApp as outlook.application
dim oNS as outlook.namespace
dim oTasks as outlook.mapifolder
dim oPublicFolders as outlook.mapifolder
dim oPublicTasks aas outlook.mapifolder
dim i as integer
set oapp = new outlook.application
set ons = oapp.getnamespace("MAPI")
set otasks = ons.getdefaultfolder(olfoldertasks)
set opublicfolders = ons.getdefaultfolder(olpublicfoldersallpublicfolders)
set opublictasks = opublicfolders.folders("all public folders").folders("TasksCopy")
for i = 1 to otasks.items.count
otasks.items(i).copy opublictasks
next
'clean up
set otasks = nothing
set opublictasks = nothing
set opublicfolders = nothing
set ons = nothing
set oapp = nothing
Last edited by RobDog888; Aug 31st, 2005 at 11:05 AM.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 1st, 2005, 06:18 AM
#3
Thread Starter
New Member
Re: Outlook: Copy a Task to another Task Folder
Hi RobDog!
Thanks a lot for your help!
I'll probably need some extra code because the destination folder is indeed inside an other pst files.
You ask me about Public ShareFolder if it was creating only several files or only a single one. In fact it's not creating a file but I guess it's accessing a remote Outlook.pst on another computer of the network.
Anyway, I've tested your code on my Outlook to try to copy a task inside another "MAPI" folder but I unfortunately have an execution error: "can't find the object" on the following line :
Set oPublicFolders = oNS.GetDefaultFolder(olPublicFoldersAllPublicFolders)
It seems to recognize what "olPublicFoldersAllPublicFolders" is: If I run step to step the macro olPublicFoldersAllPublicFolders contant = 18 but Outlook can't set oPublicFolders. If you have any idea about this error...
Thanks
Yann
-
Sep 1st, 2005, 11:29 AM
#4
Thread Starter
New Member
Re: Outlook: Copy a Task to another Task Folder
Hi RobDog!
I guess I've found out what was the problem in your code. I went on the foolowing website to obtain more information about olPublicFoldersAllPublicFolders and GetDefaultFolder. It looks like the method is not allowed to open a couple of folders: one of them is olPublicFoldersAllPublicFolders
http://msdn.microsoft.com/library/de...HV05247519.asp
Perhaps do you know (or anybody else on the forum) another way to do it?
Thanks
Yann
-
Sep 1st, 2005, 06:57 PM
#5
Re: Outlook: Copy a Task to another Task Folder
Nope, not the issue. If you read the description and the function name, its a different function. GetDefaultFolder vs. GetSharedDefaultFolder.
Microsoft Outlook does not allow you to open the following folders using the GetSharedDefaultFolder method. Therefore, the following constants cannot be used with this method:
Deleted Items - olFolderDeletedItems
OutBox - olFolderOutbox
Sent Items - olFolderSentMail
All Public Folders - olPublicFoldersAllPublicFolders
As I had mentioned in a previous post, if your destination folder is in another pst file then you need extra code to open the pst and add it to your session. Then you can transverse its folder structure for pasting in the copied task.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 1st, 2005, 07:04 PM
#6
Re: Outlook: Copy a Task to another Task Folder
ARRRRG!!! I lost my post to that stupid connection error we have been getting hammered with lately.
Anyways I will try to repost what I had posted....
If you are running in an Exchange environment then you will have a Public Folders folder. This is truely public. If you are not running Exchange and only opening another users shared folder then its a Shared folder and not public. 
You need to look at the AddStore and AddStoreEx functions of the NameSpace object in order to add the other pst file to your current Outlook session. After its added then you can tranverse the folder structure to paste your copied task.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 5th, 2005, 09:18 AM
#7
Thread Starter
New Member
Re: Outlook: Copy a Task to another Task Folder
Thanks for your advice!
I've managed to add the other PST file to my current Outlook session but I still can't access the tasks inside the new folder.
In fact I don't really know which method or function I have to use to acess items in the new foder...
I've tried to modified the piece of code you gave me but there is no results until now...
This is the modified code if you can tell me what's wrong... (I'm not using Exchange so I suppose that's only a Share Folder)
Thanks
VB Code:
Sub TaskCopy()
Dim oApp As Outlook.Application
Dim oNS As Outlook.NameSpace
Dim oTasks As Outlook.MAPIFolder
Dim oPublicFolders As Outlook.MAPIFolder
Dim oPublicTasks As Outlook.MAPIFolder
Dim i As Integer
CreatePST
Set oApp = New Outlook.Application
Set oNS = oApp.GetNamespace("MAPI")
Set oTasks = oNS.GetDefaultFolder(olFolderTasks)
Set oPublicFolders = oNS.GetSharedDefaultFolder(olFolderTasks)
Set oPublicTasks = oPublicFolders.Folders("NewFolderName")
For i = 1 To oTasks.items.Count
oTasks.items(i).Copy oPublicTasks
Next
'clean up
Set oTasks = Nothing
Set oPublicTasks = Nothing
Set oPublicFolders = Nothing
Set oNS = Nothing
Set oApp = Nothing
End Sub
Sub CreatePST()
Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Set myNameSpace = myOlApp.GetNamespace("MAPI")
myNameSpace.AddStore "\\serveur\Outlook\Outlook.pst"
End Sub
-
Sep 5th, 2005, 09:30 AM
#8
Re: Outlook: Copy a Task to another Task Folder
Why are you still using GetSharedDefaultFolder instead of GetDefaultFolder? I dont see where your opening the store and setting a MAPIFolder object to the destination folder in the store? Aso, your looping and copying tasks but not doing anything with them. So your overwritting the clipboard each time with the next one.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 6th, 2005, 05:54 AM
#9
Thread Starter
New Member
Re: Outlook: Copy a Task to another Task Folder
Hi RobDog,
Why was I Still using GetSharedDefaultFolder instead of GetDefaultFolder?
Because I thought I had to use it as far as I was using another pst file which was not the current user's file.
In fact when I use this command: MyNameSpace.AddStore "\\serveur\Outlook\Outlook.pst",
I suppose I add a new store in the MAPI Folder. As a result I can see a new "Personal Folder" in my mail list window
Then I need to access items inside this new store but before I've got to call this new folder...
So my question is : How to named this new folder?
for instance : MyNewFolder = MyNameSpace.AddStore "\\serveur...." then I could Set MyNewFloder as a new MAPI Object with the GetDefaultFolder method if I'm right!
I hope my post is clear enough. I'm really sorry for all these questions which can be perhps silly to you but I'm just beginning to understand how Outlook programming is working and the main part is still obscure... but I'm not giving up
So thank you for your patience
-
Sep 6th, 2005, 10:34 AM
#10
Re: Outlook: Copy a Task to another Task Folder
Good to hear your not giving up 
Ok, I see what your saying. GetDefaultFolder only works for the top level default folders Outlook create by default - Inbox, Calendar, Tasks, SentItems, etc).
If the other users folder you want to open in the other users pst is a Default folder then GetSharedDefaultFolder will be ok. If its a custom folder then you need the .Folders collection.
I'll see if I can write up an example for you later today when I finish my work.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 7th, 2005, 05:05 AM
#11
Thread Starter
New Member
Re: Outlook: Copy a Task to another Task Folder
Hi RobDog!
I've been trying to find a way to call that folder but I'm still looking for a solution.
I'm going to make a break with it for a while because I've got one week holidays and I'll be far away from my computer... but I'll be back anyways
See you then
-
Sep 7th, 2005, 10:29 AM
#12
Re: Outlook: Copy a Task to another Task Folder
Ok, have a good time. I havent been able to test the Shared folder method since I dont have another user to share from. BUMP the thread when your back.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 15th, 2005, 03:05 AM
#13
Thread Starter
New Member
Re: Outlook: Copy a Task to another Task Folder
I really had a good time. Thanks
That's so pleasant to take a break sometimes...
Anyway, you told me about the Shared folder method you haven't tested yet? I'm now ready to test it if you want!
-
Sep 20th, 2005, 05:55 PM
#14
Re: Outlook: Copy a Task to another Task Folder
The issue is that I am not running in an Exchange environment so its really hard to test without having the share options.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|