Sorry, I meant to attach sample code:
public class Connect : Object, Extensibility.IDTExtensibility2
{
private Outlook.Application outlook;
private static JarioLogger log = null;
private object newItem = null;
public void OnConnection(object application, Extensibility.ext_ConnectMode
connectMode, object addInInst, ref System.Array custom)
{
log =
JarioLogger.getInstance(System.Reflection.MethodBase.GetCurrentMethod().Decl
aringType);
//System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
if(log.IsInfoEnabled) log.Info("<OnConnection>");
try
{
outlook = (Outlook.Application)application;
outlook.ItemSend += new
Outlook.ApplicationEvents_ItemSendEventHandler(outlook_ItemSend);
}
catch(Exception ex)
{
if(log.IsErrorEnabled) log.Error("<OnConnection>","An error occured",
ex);
}
}
public void OnDisconnection(Extensibility.ext_DisconnectMode
disconnectMode, ref System.Array custom)
{
if(log.IsDebugEnabled) log.Debug("<OnDisconnection>");
disposeObject(newItem);
disposeObject(addInObj);
disposeObject(outlook);
if(log.IsDebugEnabled) log.Debug("<OnDisconnection>","Finished");
}
public void OnAddInsUpdate(ref System.Array custom)
{
if(log.IsDebugEnabled) log.Debug("<OnAddInsUpdate>");
}
public void OnStartupComplete(ref System.Array custom)
{
if(log.IsDebugEnabled) log.Debug("<OnStartupComplete>");
}
public void OnBeginShutdown(ref System.Array custom)
{
if(log.IsDebugEnabled) log.Debug("<OnBeginShutdown>");
}
private void outlook_ItemSend(object Item, ref bool Cancel)
{
if(log.IsDebugEnabled) log.Debug("<outlook_ItemSend>");
newItem = Item;
}
private void disposeObject(object obj)
{
if(log.IsDebugEnabled) log.Debug("<disposeObject>");
try
{
// Can't dispose null objects!!
if(obj == null)
return;
// Loop until all references are removed
int count = Marshal.ReleaseComObject(obj);
while(count > 0)
{
count = Marshal.ReleaseComObject(obj);
}
}
catch(Exception ex)
{
if(log.IsErrorEnabled) log.Error("<disposeObject>", "An error occured",
ex);
}
obj = null;
}
}
"Chris Koiak" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I'm trying to catch the ItemSend event for Outlook 2000 (and upwards) via
a
> .NET addin. This works fine when outlook is loaded and the user presses
the
> Send button. However if the user sends an email by selecting a file,
> right-clicking and selecting Send To --> Mail recipient, I experience
> problems. The email is sent correctly, the event thrown and outlook
closes,
> but windows explorer hangs. THe only way out of this is to kill the
explorer
> process!
>
> Anyone got any ideas?
>
> Thanks
> Chris Koiak
>
>
|