![]() |
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. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
Thanks Ken for your help on this.
Only problem is I do not maintain a reference to this contact until I am trying to find it when the button is clicked: I use this code to get the object: object item = this.OutlookApp.GetNamespace("MAPI").GetItemFromID (entryID, storeID); but I do not maintain a reference to item outside of this function call. If I get the item as above and then call: System.Runtime.InteropServices.Marshal.ReleaseComO bject(item); GC.Collect(); GC.WaitForPendingFinalizers(); it does not seem to do anything about releasing the cache. Any ideas? Thanks so much as always Ken Slovak - [MVP - Outlook] wrote: Have you released all references to the original object and since you're using .NET code also called Marshal.ReleaseCOMObject and called the garbage collector? Outlook caches items and their properties and the fact that things work if you close and restart Outlook makes it look like it's a caching problem. As long as an item is cached it will return its original properties back. |
#2
|
|||
|
|||
![]()
Well, I'm sorry to tell you nothing really looks wrong in your code
![]() The only thing I can think of and it's a stretch, is that you might try getting each component object as a separate object instead of using dot operators, where Outlook always creates internal variables. So for example set a NameSpace object and use that to call the GetItemFromID method. Also see if you are doing anything further on in that code that might call a procedure or item method that somehow might also be creating an implicit object variable that isn't being released when expected. I'd also be curious to see if you put up some button or something and waited a while, like 5 minutes, before clicking it and seeing if the GetItemFromID code worked then. Just for testing of course. -- 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 "Rog" wrote in message ... Thanks Ken for your help on this. Only problem is I do not maintain a reference to this contact until I am trying to find it when the button is clicked: I use this code to get the object: object item = this.OutlookApp.GetNamespace("MAPI").GetItemFromID (entryID, storeID); but I do not maintain a reference to item outside of this function call. If I get the item as above and then call: System.Runtime.InteropServices.Marshal.ReleaseComO bject(item); GC.Collect(); GC.WaitForPendingFinalizers(); it does not seem to do anything about releasing the cache. Any ideas? Thanks so much as always |
#3
|
|||
|
|||
![]()
Yes it seems if I do wait some period of time after deleting an item
from the contacts folder it will be picked up that it has moved into the Deleted Items Folder. What is odd too is, I used OutlookSpy to look at PR_PARENT_ENTRYID and it shows the deleted items folder enntry, but if I use the same in my code: safeMailitem.get_Fields(235471106); it will return the entryid of the Contacts folder. Ken Slovak - [MVP - Outlook] wrote: Well, I'm sorry to tell you nothing really looks wrong in your code ![]() The only thing I can think of and it's a stretch, is that you might try getting each component object as a separate object instead of using dot operators, where Outlook always creates internal variables. So for example set a NameSpace object and use that to call the GetItemFromID method. Also see if you are doing anything further on in that code that might call a procedure or item method that somehow might also be creating an implicit object variable that isn't being released when expected. I'd also be curious to see if you put up some button or something and waited a while, like 5 minutes, before clicking it and seeing if the GetItemFromID code worked then. Just for testing of course. |
#4
|
|||
|
|||
![]()
All that means is that something is holding a reference to the original item
and it's taking a while for it to go away. That's classic behavior for something that's finally getting hit by the garbage collector and not being fully released until then. You're going to have to put your detective's hat on to find what that is. -- 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 "Rog" wrote in message ... Yes it seems if I do wait some period of time after deleting an item from the contacts folder it will be picked up that it has moved into the Deleted Items Folder. What is odd too is, I used OutlookSpy to look at PR_PARENT_ENTRYID and it shows the deleted items folder enntry, but if I use the same in my code: safeMailitem.get_Fields(235471106); it will return the entryid of the Contacts folder. |
#5
|
|||
|
|||
![]()
thanks Ken, do you have any suggestions or tools that may help me to
figure that out? Ken Slovak - [MVP - Outlook] wrote: All that means is that something is holding a reference to the original item and it's taking a while for it to go away. That's classic behavior for something that's finally getting hit by the garbage collector and not being fully released until then. You're going to have to put your detective's hat on to find what that is. |
#6
|
|||
|
|||
![]()
No, not really. It's a matter of looking over each line of your code with a
microscope and checking for creation of implicit variables (from using compound dot operators instead of explicitly declared variables for each dot operator), making sure everything is explicitly released instead of relying on things to go out of scope and other best practices. -- 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 "Rog" wrote in message ... thanks Ken, do you have any suggestions or tools that may help me to figure that out? |
#7
|
|||
|
|||
![]()
OK so for example if I get a list of contacts like
GetNamespace("MAPI").GetDefaultFolder(OlDefaultFol ders.olFolderContacts).Items; and I use it, do I need to release it when I am done with these items? Also if I say: object item = GetFolderFromId(entry, store); do I need to release this item and garbage collect everytime when I am done with it? rog Ken Slovak - [MVP - Outlook] wrote: No, not really. It's a matter of looking over each line of your code with a microscope and checking for creation of implicit variables (from using compound dot operators instead of explicitly declared variables for each dot operator), making sure everything is explicitly released instead of relying on things to go out of scope and other best practices. |
#8
|
|||
|
|||
![]()
Also do you have a place to go where I can learn these best practices?
Rog Ken Slovak - [MVP - Outlook] wrote: No, not really. It's a matter of looking over each line of your code with a microscope and checking for creation of implicit variables (from using compound dot operators instead of explicitly declared variables for each dot operator), making sure everything is explicitly released instead of relying on things to go out of scope and other best practices. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Deleted email not going to Deleted Items folder | techie_comps | Outlook - General Queries | 1 | February 27th 06 05:59 PM |
2 different Deleted Items folders?? | Al Clark | Outlook - General Queries | 1 | February 21st 06 10:49 AM |
Inbox, Sent Items & Outbox in Deleted Items in Outlook 2003 & OWA with Exchange | splounx | Outlook - General Queries | 1 | February 17th 06 03:22 AM |
Recover Deleted Items | Paul Johnson | Outlook - General Queries | 1 | February 9th 06 04:10 PM |
how to clear deleted items? | [email protected] | Outlook - General Queries | 3 | January 16th 06 03:36 PM |