JMail收发邮件异常?
最近要做个邮件自动处理系统,从网上下载了JMail4.5的组件。
用它自带的Visual C++例子程序,执行一直报异常 E_UNEXPECTED.
不知道是什么原因。我的环境是VS2008,XP。
/*************************************************** ** Produced by Dimac ** ** More examples can be found at ** http://tech.dimac.net ** ** Support is available at our helpdesk ** http://support.dimac.net ** ** Our main website is located at ** http://www.dimac.net ** ***************************************************/// Example of using JMail from C++ using ATL.// The JMail.tlb file is required for this example. #include "stdafx.h" #include <iostream> #import "..\..\jmail.dll" // The path to the jmail.dll file here!// The strings later used as parameters to JMail// And of course they should be edited before building this project. const char *sender = "me@mydomain.com"; // Edit this!! const char *recipient = "recipient@hisdomain.com"; // Edit this!! const char *subject = "Hello JMail!"; const char *body = "This message was sent with JMail version 4.0\n" "using the JMailCppEx example!\n"; const char *mailserver = "mymailserver.mydomain.com"; // Edit this!! int main(int argc, char* *argv) { CoInitialize(NULL); { try { // jmail::ISpeedMailerPtr is generated and declared by the #import directive. jmail::ISpeedMailerPtr spJMail("JMail.SpeedMailer"); // Ok, send the mail. spJMail->SendMail( sender, recipient, subject, body, mailserver ); } catch( _com_error & E) { int a = 1; } } CoUninitialize(); return 0; }