| Dart Home | PowerTCP Mail for ActiveX | Custom Development | Reply | PowerTCP Mail for ActiveX Topics | Forums |
| Author | Forum: PowerTCP Mail for ActiveX Topic: Event Sinks and DartMail component |
| cjoyce From: Apex, NC USA Posts: 9 Member Since: 03/25/02 |
posted March 25, 2002 6:44 PM Hi, I've looked at the MFC sample you provided. I'm trying to create a mail service in C++/ATL that creates an instance of DartMail and serves up email requests. I need to monitor the events so I know when a timeout or other error occurs. I've successfully received a status event but the error and progress events cause an exception (E_INVALIDARG) when ATL tries to figure out the parameters list. I have tried EVERYTHING to get this working. Have you created a sample in ATL/C++? I would really appreciate some help. We were using the component on some server-side VBScript but it errors out occasionally so we need something more robust that handles errors gracefully. Any ideas as to why this is happening? I've used event sinks before with some of our components and they work just fine with parameters. Thanks. |
Tony Priest![]() From: Utica, NY USA Posts: 8466 Member Since: 04/11/00 |
posted March 25, 2002 7:21 PM I've never written an ATL app (other than our controls) but I can tell you what we do internally and what is different between the events with parameters. I'll use the TCP control that we use internally in my description. The first thing that I notice is that the SINK_ENTRY info is different: // setup sink for embedded TCP control events BEGIN_SINK_MAP(CPop) SINK_ENTRY_EX(1,DIID__ITcpEvents, 0x1, TCPState) SINK_ENTRY_INFO(1,DIID__ITcpEvents, 0x2, TCPError, &TcpErrorInfo) SINK_ENTRY_EX(1,DIID__ITcpEvents, 0x3, TCPReceive) SINK_ENTRY_EX(1,DIID__ITcpEvents, 0x4, TCPSend) END_SINK_MAP() TcpErrorInfo is defined as follows: static _ATL_FUNC_INFO TcpErrorInfo = { CC_STDCALL, VT_I4, 2, {VT_I4, VT_BSTR} }; The TCPError functions is defined like this: void __stdcall CPop::TCPError(ErrorConstants Number, BSTR Description) Hope this helps! Tony Priest Dart Tech Support |
| cjoyce From: Apex, NC USA Posts: 9 Member Since: 03/25/02 |
posted March 26, 2002 1:30 PM Thanks Tony. That did the trick. I was using the VT_USERDEFINED variant type for the enums and VT_ERROR for the HRESULT return type - that appeared to be causing the error. For the benefit of anyone else using the DartMail component in ATL, here's my header: //Email component #import <dartmail.dll> no_namespace raw_interfaces_only named_guids //Unique identifier for event sink #define DART_EVENTS_ID 0 //Dispatch IDs for Dart SMTP ISmtpEvents interface #define DISPID_ON_ERROR 1 #define DISPID_ON_STATE 2 #define DISPID_ON_PROGRESS 3 //Define _ATL_FUNC_INFO structures for 2 events that accept parameters - used in SINK_ENTRY_INFO static _ATL_FUNC_INFO ErrorEventInfo = {CC_STDCALL, VT_I4, 2, {VT_I4, VT_BSTR} }; static _ATL_FUNC_INFO ProgressEventInfo = {CC_STDCALL, VT_I4, 5, {VT_I4, VT_I4, VT_BSTR, VT_I4, VT_I2} }; class EmailServer : public IDispEventImpl<DART_EVENTS_ID, EmailServer, &DIID__ISmtpEvents, &LIBID_DartMail, 1, 0> { public: //Constructor and Destructor EmailServer(); ~EmailServer() //Public methods bool ProcessJob(); protected: //Event sink for ISmtpEvents dispinterface BEGIN_SINK_MAP(EmailServer) SINK_ENTRY_INFO(DART_EVENTS_ID, DIID__ISmtpEvents, DISPID_ON_ERROR, OnError, &ErrorEventInfo) SINK_ENTRY_EX(DART_EVENTS_ID, DIID__ISmtpEvents, DISPID_ON_STATE, OnState) SINK_ENTRY_INFO(DART_EVENTS_ID, DIID__ISmtpEvents, DISPID_ON_PROGRESS, OnProgress, &ProgressEventInfo) END_SINK_MAP() void __stdcall OnError(ErrorConstants Number, BSTR Description); void __stdcall OnProgress(SmtpMethodConstants Command, SmtpStatusConstants Status, BSTR Reply, long Count, int Size); void __stdcall OnState(); private: //Member Variables ISmtp* m_pSMTPServer; //Single instance of DartMail component }; |
| Reply | PowerTCP Mail for ActiveX Topics | Forums |
This site is powered by
PowerTCP WebServer for ActiveX
|