A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Close item



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 16th 09, 03:32 PM posted to microsoft.public.outlook.program_vba
Richard Elgert
external usenet poster
 
Posts: 3
Default Close item

I am trying to open/read all email in the inbox.. (trying to delete duplicates)

Get error at 250th item sayin the system settings do not allow any more open than that

have this in code
' need to close the email
oMsg.Close(OlInspectorClose.olSave)

but does not close the mail item

how do I close properly so no error

Ads
  #2  
Old June 16th 09, 06:48 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Close item

Managed code with Exchange mailbox? That's the RPC channel limit, unless the
object reference is released that error will result after about 250 or so
operations.

Set the object to null each pass through the code, if necessary also call
Marshal.ReleaseComObject() on it and GC.Collect(). That will release all
those RPC channels that otherwise wouldn't be released until the procedure
ended and the objects went out of scope.

Also don't use concatenated dot operators:

string body = olApp.ActiveInspector.CurrentItem.Body;

Set up a variable for each dot operator so you can explicitly release
things. Otherwise intrinsic variables are created internally and you cannot
release those:

Outlook.Inspector insp = olApp.ActiveInspector;
Outlook.MailItem item = (Outlook.MailItem)insp.CurrentItem;
string body = item.Body;


--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Richard Elgert" relgert[at]tct-inc[dot]com wrote in message
...
I am trying to open/read all email in the inbox.. (trying to delete
duplicates)

Get error at 250th item sayin the system settings do not allow any more
open than that

have this in code
' need to close the email
oMsg.Close(OlInspectorClose.olSave)

but does not close the mail item

how do I close properly so no error


Submitted using http://www.outlookforums.com


  #3  
Old June 17th 09, 10:32 AM posted to microsoft.public.outlook.program_vba
Richard Elgert
external usenet poster
 
Posts: 3
Default Close item

retValue = System.Runtime.InteropServices.Marshal.ReleaseComO bject(oMsg )
GC.Collect()

OK I did add the above 2 lines and the 250 limit error is gone.... but I am not sure I fully understand... (will your book clarify)

and a follow up, I need to browse all folders and sub-folders in a users mailbox. .
Submitted using http://www.outlookforums.com
  #4  
Old June 17th 09, 03:55 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Close item

My book might mention the RPC limit but it's strictly an Exchange setting
that's controlled by a registry setting on the server. It limits how many
RPC channels any application can open at any one time so as not to bog down
the server. Since the setting can be anything if the admins change the
default, all you really need to understand is to follow best practices and
release your objects as soon as they are not needed and not to create
intrinsic object variables by using compound dot operators, especially
within loops where the objects will persist until the procedure running the
loop has ended.

I don't understand your question about folder browsing. Just use a recursive
procedure that digs into each MAPIFolder.Folders collection, starting with
the NameSpace.Folders collection or at a selected starting point.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Richard Elgert" relgert[at]tct-inc[dot]com wrote in message
...
retValue = System.Runtime.InteropServices.Marshal.ReleaseComO bject(oMsg )
GC.Collect()

OK I did add the above 2 lines and the 250 limit error is gone.... but I
am not sure I fully understand... (will your book clarify)

and a follow up, I need to browse all folders and sub-folders in a users
mailbox. . Submitted using http://www.outlookforums.com


  #5  
Old June 17th 09, 06:13 PM posted to microsoft.public.outlook.program_vba
Richard Elgert
external usenet poster
 
Posts: 3
Default Close item

Well to make a long story short... the whole purpose of this exercise was to delete duplicate emails... from several import of lotus Notes int Outlook, we wound up with hundreds of dupes. Tried the 'ODIR' recommended program, but that did not delete them... my code test showed that they all had a unique record ID.
Bought "Duplicate Email Remover" for $30 dollars and that did the job just fine...
I will work on my code when time permits....
Submitted using http://www.outlookforums.com
 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
When I close an email item, the whole program shuts down. Beckiet Outlook - General Queries 1 March 9th 09 10:11 PM
Alternative to item.close flaterp Outlook - Using Forms 3 October 29th 08 05:44 PM
Function Item.close Outlook 2007 JCCKIKI Outlook - Using Forms 2 October 3rd 07 11:01 AM
Outlook 2007 and Item.Close slbergh Outlook - Using Forms 2 June 8th 07 06:11 AM
Item.Save and Item.Close Script causes Outlook 2007 to Crash Rayyan Outlook - Using Forms 6 November 25th 06 03:14 AM


All times are GMT +1. The time now is 09:42 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2024 Outlook Banter.
The comments are property of their posters.