Try getting the Item.EntryID and releasing the Item after saving it. Then
get the same item using NameSpace.GetItemFromID and use that to copy/move
and see if that works better.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
"meokey" wrote in message
...
In a section of VBA in Outlook, I need to copy a appointment item (named
Item, in PST file) to another Calendar in Mailbox of Exchange server. I
add a
UserProperty, RndID, to the appointmentitem, Item. But I find the
userproperty didn't be copied.
The code is as following:
Set myprop = Nothing
Set myprop = Item.UserProperties.Find("RndID")
If TypeName(myprop) = "Nothing" Then
Set myprop = Item.UserProperties.Add("RndID", olNumber)
myRndID = Int(Rnd() * 100000)
Item.UserProperties("RndID").Value = myRndID
Item.Save
End If
........
Item.Body = "testtest" & " " & myRndID
Item.Save
Set myCopiedItem = Item.Copy
myCopiedItem.Move myMailboxCal
MsgBox myCopiedItem.UserProperties("RndID").Value, , "Copied to
Mailbox"
The last code, which is to validate whether the whole item including all
properties is copied, failed with the message: Object variable or With
block
variable not
set. Of couse, the body of the appointmentitem in Mailbox is blank. It
shows
that the properties of RndID and Body of Item in PST did NOT be copied to
myCopiedItem and moved to myMailboxCal.
Any comments/suggestions will be very appreciated.