请用该函数写一个发送邮件的完整程序的例子,如果您有更简单发送邮件的方法也请写出!谢谢!

解决方案 »

  1.   

    #import <cdonts.dll>
    #include "tchar.h"
    #include "stdio.h"
    void main()
    {
    //The SMTP server should be running.
    CoInitialize(NULL);
    try
    {
         CDONTS::INewMailPtr spNewMail(__uuidof(CDONTS::NewMail));
         spNewMail->From = _T("YourName");
         spNewMail->To = _T("[email protected]");
         spNewMail->Subject = _T("Testing");
         spNewMail->Body = _T("Put your message here");
     spNewMail->AttachFile(_variant_t(_bstr_t("C:\\tmp\\test\\mail\\mail.cpp")),_variant_t((long)DISP_E_PARAMNOTFOUND, VT_ERROR),_variant_t((long)DISP_E_PARAMNOTFOUND, VT_ERROR));
         spNewMail->Send();
     printf("send ok");
    }
    catch(_com_error &ComError)
    {
         // Error handling goes here
    printf("%s\n",ComError.Description());
    }
    CoUninitialize();
    }
      

  2.   

    我用的是VC5,没有cdonts.dll库文件,还请你用MAPISendMail()函数写一个例子,谢谢