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 » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Direction/Help required for not to save MailItems in Sent Folder



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #9  
Old October 1st 07, 02:48 PM posted to microsoft.public.outlook.program_addins
PS
external usenet poster
 
Posts: 35
Default Direction/Help required for not to save MailItems in Sent Folder

Ken

I was implementing the above discussed content and am getting an error
(which I believe shouldnt be the case) when working with the Mail
Close logic

In the MailItem_Send event as discussed - after setting Cancel = true
- in the end I start a timer event which lets say gets called after 3
seconds

But still get this error on
Marshal.FinalReleaseComObject(myMailItem);:

Error Text:
RaceOnRCWCleanup was detected
Message: An attempt has been made to free an RCW that is in use. The
RCW is in use on the active thread or another thread. Attempting to
free an in-use RCW can cause corruption or data loss.

Code he

private void MailItem_ItemSend(ref bool Cancel)
{
Business Logic here..

If certain business condition is true then.
Cancel = true
Then Timer Logic (which is below)
Timer delay = new Timer();
delay.Enabled = true;
delay.Interval = 10000;
delay.Tick += new EventHandler(delay_Tick);
}

void delay_Tick(object sender, EventArgs e)
{
myMailItem.Close(Ol.OlInspectorClose.olSave);
Or Even tried below:
myMailItem.Delete();
}

private void MailItem_ItemClose(ref bool Cancel)
{
try
{
//Execute cleanup only if the item has not changed, b'coz the
message box prompts users to save the message is displayed
//after this event. That message box also gives the user
the ability to cancel the event
//so we do not want to unwire the events here if the
message is "dirty"
if (this.isSent || myMailItem.Saved)
{
CleanMailItemEvents();
//Some more cleannup
}
}
}

public void CleanMailItemEvents()
{
Ol.ItemEvents_10_Event _myMailItemEvents = myMailItem as
Ol.ItemEvents_10_Event;
_myMailItemEvents.Close -= new
Ol.ItemEvents_10_CloseEventHandler(MailItem_ItemCl ose);
_myMailItemEvents.Send -= new
Ol.ItemEvents_10_SendEventHandler(MailItem_ItemSen d);
_myMailItemEvents.Forward -= new
Ol.ItemEvents_10_ForwardEventHandler(MailItem_Item Forward);
_myMailItemEvents.Reply -= new
Ol.ItemEvents_10_ReplyEventHandler(MailItem_ItemFo rward);
_myMailItemEvents.ReplyAll -= new
Ol.ItemEvents_10_ReplyAllEventHandler(MailItem_Ite mRelpyAll);
_myMailItemEvents = null;
Marshal.FinalReleaseComObject(myMailItem);
myMailItem = null;
}

 




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
Hot to speed up MailItems access Ivan Add-ins for Outlook 8 June 27th 07 06:39 PM
Move MailItems to another folder Gvaram Outlook and VBA 5 June 25th 07 01:46 PM
Could not save item. the form required to view this message cannot matt hullinger Outlook - Calandaring 1 February 20th 07 11:48 PM
Can someone point me in the right direction configuring Outlook To Sam Outlook - Installation 0 June 8th 06 03:25 AM
How To: select mailitems from my inbox? NFR Outlook - Using Forms 1 May 16th 06 04:41 PM


All times are GMT +1. The time now is 01:17 PM.


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