|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Can I implement web storage event handlers in .NET?Hi there
Can I implement web storage event handlers in .NET? Are there examples somewhere? C#? I can't see which interface to implement in the Microsoft.Exchange.Transport.EventWrappers.dll which I have compiled from the Exchange SDK. Or I'm a just blind? ;-) If not, are there somewhere C++ examples? Regards, Stephan Bachofen Those wrappers are for SMTP event sinks for store sinks have a look at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wss/wss/_esdk_building_managed_event_sink_dlls.asp which details how build the interops required. Cheers Glen Show quote "sba" <sbadoesn***@gmx.net> wrote in message news:1121097852.281975.5700@g14g2000cwa.googlegroups.com... > Hi there > > Can I implement web storage event handlers in .NET? Are there examples > somewhere? C#? > I can't see which interface to implement in the > Microsoft.Exchange.Transport.EventWrappers.dll which I have compiled > from the Exchange SDK. Or I'm a just blind? ;-) > If not, are there somewhere C++ examples? > > Regards, > Stephan Bachofen > Thank you very much for your help. I followed the instructions posted
at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wss/wss/_esdk_building_managed_event_sink_dlls.asp and I was able to compile my handler. What I'm stock with is the registration: regasm WebStoreEventSink.dll regasm Interop.Exevtsnk.dll regasm Interop.Exoledb.dll Executing (as Administrator) D:\Working>cscript RegEvent.vbs add "onsave" WebStoreEventSink.WebStoreEventSink Handler.1 file://./backofficestorage/exchange.svr/mbx/sba/inbox/EventRegItem1 -m deep returns Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. Error Opening Record : -2147024891 Access is denied. The user sba exists and I can send and receive mail. What I find odd is the fact that D:\Working>dir \\.\backofficestorage\exchange.svr\MBX\sba Volume in drive \\.\backofficestorage is Exchange Volume Serial Number is 00A9-8AC7 Directory of \\.\backofficestorage\exchange.svr\MBX 22.07.2005 12:25 <DIR> sba 0 File(s) 0 bytes 1 Dir(s) 10'081'816'576 bytes free D:\Working> folder sba has not content. I expected some Inbox folder. Source code of my handler: namespace WebStoreEventSink { /// <summary> /// Summary description for Class1. /// </summary> public class WebStoreEventSinkHandler { public class AsyncEvents : ServicedComponent, Exoledb.IExStoreAsyncEvents { public void OnDelete(Exoledb.IExStoreEventInfo pEventInfo, string bstrURLItem, int lFlags) { // Implement OnDelete code here. } public void OnSave(Exoledb.IExStoreEventInfo pEventInfo, string bstrURLItem, int lFlags) { { EventLog myLog = new EventLog(); myLog.Source = "WebStoreEventSinkHandler"; // Write an informational entry to the event log. myLog.WriteEntry("Executing WebStoreEventSinkHandler::OnSave -> bstrURLItem:\"" + bstrURLItem + "\"."); } } } } } Thank you very much for your help. I followed the instructions posted
at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wss/wss/_esdk_building_managed_event_sink_dlls.asp and I was able to compile my handler. What I'm stock with is the registration: regasm WebStoreEventSink.dll regasm Interop.Exevtsnk.dll regasm Interop.Exoledb.dll Executing (as Administrator) D:\Working>cscript RegEvent.vbs add "onsave" WebStoreEventSink.WebStoreEventSink Handler.1 file://./backofficestorage/exchange.svr/mbx/sba/inbox/EventRegItem1 -m deep returns Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. Error Opening Record : -2147024891 Access is denied. The user sba exists and I can send and receive mail. What I find odd is the fact that D:\Working>dir \\.\backofficestorage\exchange.svr\MBX\sba Volume in drive \\.\backofficestorage is Exchange Volume Serial Number is 00A9-8AC7 Directory of \\.\backofficestorage\exchange.svr\MBX 22.07.2005 12:25 <DIR> sba 0 File(s) 0 bytes 1 Dir(s) 10'081'816'576 bytes free D:\Working> folder sba has not content. I expected some Inbox folder. Source code of my handler: namespace WebStoreEventSink { /// <summary> /// Summary description for Class1. /// </summary> public class WebStoreEventSinkHandler { public class AsyncEvents : ServicedComponent, Exoledb.IExStoreAsyncEvents { public void OnDelete(Exoledb.IExStoreEventInfo pEventInfo, string bstrURLItem, int lFlags) { // Implement OnDelete code here. } public void OnSave(Exoledb.IExStoreEventInfo pEventInfo, string bstrURLItem, int lFlags) { { EventLog myLog = new EventLog(); myLog.Source = "WebStoreEventSinkHandler"; // Write an informational entry to the event log. myLog.WriteEntry("Executing WebStoreEventSinkHandler::OnSave -> bstrURLItem:\"" + bstrURLItem + "\"."); } } } } } Access denied mean access denied this is usually caused because your trying
to register the sink with a user with administrative rights. By default in Ex2x administrator accounts are explicitly denied access to any mailbox other then their own have a read of http://support.microsoft.com/?kbid=262054 which gives a solution for this. Cheers Glen Show quote "sba" <sbadoesn***@gmx.net> wrote in message news:1122033557.143398.68830@o13g2000cwo.googlegroups.com... > Thank you very much for your help. I followed the instructions posted > at > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wss/wss/_esdk_building_managed_event_sink_dlls.asp > and I was able to compile my handler. > > What I'm stock with is the registration: > regasm WebStoreEventSink.dll > regasm Interop.Exevtsnk.dll > regasm Interop.Exoledb.dll > > Executing (as Administrator) > D:\Working>cscript RegEvent.vbs add "onsave" > WebStoreEventSink.WebStoreEventSink Handler.1 > file://./backofficestorage/exchange.svr/mbx/sba/inbox/EventRegItem1 -m > deep > > returns > Microsoft (R) Windows Script Host Version 5.6 > Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. > > Error Opening Record : -2147024891 Access is denied. > > The user sba exists and I can send and receive mail. What I find odd is > the fact that > D:\Working>dir \\.\backofficestorage\exchange.svr\MBX\sba > Volume in drive \\.\backofficestorage is Exchange > Volume Serial Number is 00A9-8AC7 > > Directory of \\.\backofficestorage\exchange.svr\MBX > > 22.07.2005 12:25 <DIR> sba > 0 File(s) 0 bytes > 1 Dir(s) 10'081'816'576 bytes free > D:\Working> > > folder sba has not content. I expected some Inbox folder. > > Source code of my handler: > namespace WebStoreEventSink > { > /// <summary> > /// Summary description for Class1. > /// </summary> > public class WebStoreEventSinkHandler > { > public class AsyncEvents : ServicedComponent, > Exoledb.IExStoreAsyncEvents > { > public void OnDelete(Exoledb.IExStoreEventInfo pEventInfo, > string bstrURLItem, int lFlags) > { > // Implement OnDelete code here. > } > > public void OnSave(Exoledb.IExStoreEventInfo pEventInfo, > string bstrURLItem, int lFlags) > { > { > EventLog myLog = new EventLog(); > myLog.Source = "WebStoreEventSinkHandler"; > // Write an informational entry to > the event log. myLog.WriteEntry("Executing > WebStoreEventSinkHandler::OnSave -> bstrURLItem:\"" + bstrURLItem + > "\"."); > } > } > } > } > } > Thanks, that solved the problem with viewing the content of the folder.
As a result (and a step forward) registering the handler started to fail for a different reason: Error -2141913011 Event Registration Failure: The specified event sink (ProgID: %1) is not allowed to run in-proc. I was able to work around that error by registering the com component differently as explained here: http://www.devnewsgroups.net/group/microsoft.public.exchange.development/topic13489.aspx Basically, it is about using regsvsc instead of the Component Services admin tool. My very basic handler mentioned earlier in this thread works fine now. Although, my efforts making the handler slightly more interesting were punished immediately: The handler below seems not to fire. I can't even see the event recorded before calling the iMessage.DataSource.Open method. I believe that method is the culprit. using System; using System.Diagnostics; using System.Reflection; using Exoledb = Interop.Exoledb; using ExevtsnkLib = Interop.Exevtsnk; using System.EnterpriseServices; using CDO; using ADODB; namespace WebStoreEventSink { /// <summary> /// Summary description for Class1. /// </summary> public class WebStoreEventSinkHandler { public class AsyncEvents : ServicedComponent, Exoledb.IExStoreAsyncEvents { public void OnDelete(Exoledb.IExStoreEventInfo pEventInfo, string bstrURLItem, int lFlags) { // Implement OnDelete code here. } public void OnSave(Exoledb.IExStoreEventInfo pEventInfo, string bstrURLItem, int lFlags) { try { WriteToLog("Executing WebStoreEventSinkHandler::OnSave -> bstrURLItem:\"" + bstrURLItem + "\". Jus't been called. Lets see if I can save the mail ..."); String fileName= null; if(System.Convert.ToBoolean(lFlags)) { CDO.Message iMessage=new CDO.MessageClass(); iMessage.DataSource.Open(bstrURLItem,null, ADODB.ConnectModeEnum.adModeRead, ADODB.RecordCreateOptionsEnum.adFailIfNotExists, ADODB.RecordOpenOptionsEnum.adOpenSource,"",""); fileName= "D:\\Temp\\" + "ExchangeMail" + DateTime.Now.Ticks; // iMessage.GetStream().SaveToFile("D:\\Temp\\" + "ExchangeMail" + DateTime.Now.Ticks + ".eml",ADODB.SaveOptionsEnum.adSaveCreateNotExist); WriteToLog("Executing WebStoreEventSinkHandler::OnSave -> bstrURLItem:\"" + bstrURLItem + "\". Saved to file " + fileName); } } catch (Exception e) { WriteToLog("Executing WebStoreEventSinkHandler::OnSave -> failed. Caught exception: " + e.Message); throw e; } } void WriteToLog(String msg) { EventLog myLog = new EventLog(); myLog.Source = "WebStoreEventSinkHandler"; // Write an informational entry to the event log. myLog.WriteEntry(msg); } } } } |
|||||||||||||||||||||||