help: AppointmentItem.copy fail problem

G

Guest

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.
 
J

Jeff

As a first step, you could use Outlook or OutlookSpy to double-check
that the property did not get copied.
 
K

Ken Slovak - [MVP - Outlook]

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.
 

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