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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+