VC中自动发送邮件的实现.doc
文本预览下载声明
VC中自动发送邮件的实现现在做一个邮件发送的模块,用于邮件报警的,在网上找了两种方案,一种是调用OUT LOOK EXPREES,用MAP?I实现,另一是用SMTP协议,还没想好用哪一个呢.思考中!发送邮件:VC + socket + SMTP用VC发送邮件
.// mysmtp.h .#pragma once .#include list .#include string . .class CSocket; .class CMySmtp .{ .private: .???? static const char m_staticBase64CodeTable[]; .???? static const std::string MIMEMultipartMixedLogin; .???? static const std::string MIMETextPlainLogin; .???? static const std::string MyBoundary; .???? static const std::string CTCodeQP; .???? static const std::string CTCodeBase64; .???? static const std::string CTTextPlainCharCodeGB2312; .???? static const std::string CTAppOctetStreamName; .???? static const std::string CDAttachemntFileName; . .???? struct stSMTP .???? { .???????? int Post; .???????? std::string Host; .???????? std::string UserName; .???????? std::string Password; .???????? std::string MailFrom; .???????? std::string SendTo; .???????? std::string Subject; .???????? std::string Date; .???????? std::string Data; .???? }; .???? struct stPathFile .???? { .???????? std::string Path; .???????? std::string File; .???? }; . .???? CSocket* m_pSmtpServer; .???? stSMTP m_stSmtpPro; .???? std::list stPathFile m_listAttachmentFileName; . .public: .???? CMySmtp(void); .???? virtual ~CMySmtp(void); . .???? static int Base64EncodeLen( int nSrcLen ); .???? static bool Base64Encode( const BYTE* szSrcData, int nSrcLen, BYTE* szDestData, int* pnDestLen ); . .???? void SetPost( int t )??????????????????????? { m_stSmtpPro.Post = t; } .???? void SetHost( std::string t )??????????????? { m_stSmtpPro.Host = t; } .???? void SetUserName( std::string t )??????????? { m_stSmtpPro.UserName = t; } .???? void SetPassword( std::string t )??????????? { m_stSmtpPro.Password = t; } .???? void SetMailFrom( std::string t )??????????? { m_stSmtpPro.MailFrom = t; } .???? void SetSendTo( std::string t )????????????? { m_stSmtpPro.SendTo = t;??? } .???? void SetSubject( std::string t )???????????? {
显示全部