AppointmentItem.copy fail

M

meokey

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.
 

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