How to copy all calendar items from PST file to Exchange Folder?

A

Alan

Hi All,

I have a situation where I need to copy all the calendar items from a
PST calendar folder to an exchange calendar folder.

I can do this between the PST calendar folder and a sub-folder but not
to an exchange folder.

There are no permission issues in the exchange folder - I am the owner
and have full create, edit, delete etc permissions.

The code I have tried is below. The line that errors out is:

ObjCopy.Move ObjTarget

The error message is:

"Could not complete the operation. One or more paramteter values are
not valid."

The exact same code, including that line works fine if I substitute a
sub-folder of the PST calendar folder as the detination rather than
the exchange folder so I don't think it is a syntax issue.

When the code stops, if I choose 'debug' and check the value of
objTarget it is "Calendar" which is the name of the exchange folder.
objCopy is a valid calendar item in the source PST calendar folder, so
that appears to be okay too.

Just in case, I have ensured that there are no items in the exchange
folder prior to running the code so it cannot be a 'conflict' between
two items.

Any ideas?

Thanks,

Alan.



+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Sub Copy_Main_Cal_Items_To_Exchange()

' Declarations

Dim FolderCollection As Folders
Dim AlanMainMailFileFolders As Folders

Dim AlanCalendarFolders As Folders

Dim AlanCalendarItems As Items
Dim AlanTestDestinationCalendarItems As Items

Dim TotalItems As Integer
Dim Counter As Integer

Dim ObjTarget As MAPIFolder

Dim ObjItem As AppointmentItem
Dim ObjCopy As AppointmentItem




' Set up objects to be used

Set FolderCollection = Application.GetNamespace("MAPI").Folders

Set AlanMainMailFileFolders = FolderCollection("Alan - Main Mail
File").Folders
Set AlanCalendarItems = AlanMainMailFileFolders("Calendar").Items

Set AlanExchangeFolders = FolderCollection("Mailbox - Alan
Figgins").Folders
Set AlanExchangeCalendarFolder = AlanExchangeFolders("Calendar")



' Transfer the 'Main' calendar items to the TestDestination exchange
calendar

Set ObjTarget = AlanExchangeCalendarFolder

If Not ObjTarget Is Nothing Then

For Each ObjItem In AlanCalendarItems

Set ObjCopy = ObjItem.Copy

ObjCopy.Move ObjTarget

Set ObjCopy = Nothing

Next

End If




End Sub




+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 
A

Alan

Alan said:
Hi All,

I have a situation where I need to copy all the calendar items from
a PST calendar folder to an exchange calendar folder.

I can do this between the PST calendar folder and a sub-folder but
not to an exchange folder.

There are no permission issues in the exchange folder - I am the
owner and have full create, edit, delete etc permissions.

The code I have tried is below. The line that errors out is:

ObjCopy.Move ObjTarget

The error message is:

"Could not complete the operation. One or more paramteter values
are not valid."

The exact same code, including that line works fine if I substitute
a sub-folder of the PST calendar folder as the detination rather
than the exchange folder so I don't think it is a syntax issue.

When the code stops, if I choose 'debug' and check the value of
objTarget it is "Calendar" which is the name of the exchange folder.
objCopy is a valid calendar item in the source PST calendar folder,
so that appears to be okay too.

Just in case, I have ensured that there are no items in the exchange
folder prior to running the code so it cannot be a 'conflict'
between two items.

Any ideas?

Thanks,

Alan.



+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

{Code snipped}
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+


Hi Again,

I don't know if it is related, but to do this manually, you need to
switch to 'category' view first to select all the items (Ctrl-A).

Given that I can move them from a PST calendar folder to another
folder
in that PST file using the code posted, I cannot see how this would
matter, but you never know!

Thanks for any suggestions,

Alan.
 
G

Guest

Do you have permissions to create new items in that Public Folder? Can you
copy the items manually?
 
A

Alan

Eric Legault said:
Do you have permissions to create new items in that Public Folder?
Can you copy the items manually?


Hi Eric,

There are no permission issues in the exchange folder - I am the
owner and have full create, edit, delete etc permissions.

I can do it manually no problem, just not programmatically.


Do you know why the line:

ObjCopy.Move ObjTarget

could error out?

The error message is:

"Could not complete the operation.
One or more paramteter values are not valid."

I have to be honest - I do not know how to interpret the message in
that I don't see what the 'parameters' are in this context, and given
that the same line works fine to another PST folder it seems to be
syntactically correct.

Thanks for your assistance - I very much appreciate your involvement,

Alan.
 
G

Guest

If you search for that error message in the MS Knowledge Base, you'll see all
kinds of completely different issues in Outlook that displays the same error
message. Unfortunately, none of them are 100% relevant to your situation.
The articles that are close seem to hint at a corrupt .pst or Exchange
folder, so you may want to rule that out by running your code against a
completely new test .pst file with new test items being copied to a new
Exchange folder.

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
Try Picture Attachments Wizard for Outlook! http://tinyurl.com/ckytm
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/
 
A

Alan Alan

Eric Legault said:
If you search for that error message in the MS Knowledge Base, you'll see all
kinds of completely different issues in Outlook that displays the same error
message. Unfortunately, none of them are 100% relevant to your situation.

I agree - I had wondered if it was just me not comprehending, but thank you
for checking too.
The articles that are close seem to hint at a corrupt .pst or Exchange
folder, so you may want to rule that out by running your code against a
completely new test .pst file with new test items being copied to a new
Exchange folder.

I tried from three different PST files (including one that I created from
scratch and just entered a single calendar item to make it as safe as
possible - still the same results with the error on that same line.

Could I ask whether you are able to make it work by moving an item from a
PST calendar folder to an exchange calendar folder?

It errors out even if I create a sub-calendar folder in exchange, so there
is no need to risk you main calendar folder, but please do be careful!

Thanks,

Alan.
 
A

Alan

"Eric Legault [MVP - Outlook]" <[email protected]>
wrote in message
I tried your code and had no problems, although I did have to
declare these variables:

AlanExchangeFolders
AlanExchangeCalendarFolder

Other than that, I'm stumped.

Hi Eric,

Thank you for trying for me.

Despite my statements to the contrary, I believe it *must* be a
permissions issue, since it works for you and for me to a PST
destination outside of my exchange folders.

I will re-examine the exchange setup and see if I can work it out.

I really appreciate your assistance with this - I owe you one (or a
few)!

Regards,

Alan.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top