![]() |
| If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|||||||
| Tags: appointmentitemcopy, fail, help, problem |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
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. |
| Ads |
|
#2
|
|||
|
|||
|
As a first step, you could use Outlook or OutlookSpy to double-check
that the property did not get copied. On Oct 30, 11:07 am, meokey wrote: 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. |
|
#3
|
|||
|
|||
|
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. |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How can i make AppointmentItem not editable in the calendar? | eranhef@gmail.com | Outlook - Using Forms | 0 | September 19th 06 06:59 AM |
| How to access the Private property on a Outlook.AppointmentItem | PromisedOyster | Outlook and VBA | 1 | August 11th 06 12:26 PM |
| fail to search text in old emails | vito | Outlook - General Queries | 0 | May 18th 06 03:20 AM |
| How to create AppointmentItem in inbox (Outlook 2002) | Galois | Add-ins for Outlook | 2 | April 27th 06 08:01 AM |
| AppointmentItem question (2003) | Dana DeLouis | Outlook and VBA | 1 | January 18th 06 05:13 PM |