mailmessage.h

来自「这里实现了用smtp来发送email」· C头文件 代码 · 共 95 行

H
95
字号
// MailMessage.h: interface for the CMailMessage class.
// Copyright (c) 1998, Wes Clyburn
//////////////////////////////////////////////////////////////////////

//*** Every modification marked with <JFO>
//*** have been added by Jean-Francois Ouellet lafaune@total.net (15 dec 98)
//***
//*** These modifications have been done to enhance the real good object
//*** of Wes.Clyburn, with the functionnality of CC and BCC copy and in the
//*** context of keeping the same public interface.
//***
//*** All new parameters are only optionnal.
//***
//*** Still thanks to Wes Clyburn.

#if !defined(AFX_MAILMESSAGE_H__55DE48CC_BEA4_11D1_870E_444553540000__INCLUDED_)
#define AFX_MAILMESSAGE_H__55DE48CC_BEA4_11D1_870E_444553540000__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

#include <afxtempl.h>

// CMailMessage
// Formats a message compliant with RFC 822.
//
class CMailMessage  
{
public:
	CMailMessage();
	virtual ~CMailMessage();
	//接收人的类型,枚举结构
	enum RECIPIENTS_TYPE { TO, CC, BCC }; // <JFO>
	//格式化信息,调用了附件编码程序
	void FormatMessage();
	//获取接收人的数量
	int GetNumRecipients(RECIPIENTS_TYPE type = TO /* <JFO> */);
	//获取接收人信息
	BOOL GetRecipient( CString& sEmailAddress, CString& sFriendlyName, int nIndex = 0, RECIPIENTS_TYPE type = TO /* <JFO> */ );
	//添加接收人
	BOOL AddRecipient( LPCTSTR szEmailAddress, LPCTSTR szFriendlyName = "", RECIPIENTS_TYPE type = TO /* <JFO> */ );
	//添加多个接收人
	BOOL AddMultipleRecipients( LPCTSTR szRecipients = NULL, RECIPIENTS_TYPE type = TO /* <JFO> */ );
	//获取每行的字符数
	UINT GetCharsPerLine();
	//设定每行的字符数
	void SetCharsPerLine( UINT nCharsPerLine );
	//发信人
	CString m_sFrom;
	//主题
	CString m_sSubject;
	CString m_sEnvelope;
	//发信程序名称
	CString m_sMailerName;
	//信件头
	CString m_sHeader;
	//时间戳
	CTime m_tDateTime;	
	//邮件正文
	CString m_sBody;
	
private:
	UINT m_nCharsPerLine;
	//接收人结构
	class CRecipient
	{
	public:
		//接收人地址
		CString m_sEmailAddress;
		//接收人名称
		CString m_sFriendlyName;
	};
	//TO 链表
	CArray <CRecipient, CRecipient&> m_Recipients;
	//CC链表
	CArray <CRecipient, CRecipient&> m_CCRecipients;    
	//BCC链表
	CArray <CRecipient, CRecipient&> m_BCCRecipients;   
	
	protected:
		//准备邮件头格式
		virtual void prepare_header();
		//准备邮件正文格式
		virtual void prepare_body();
		//结束邮件头
		virtual void end_header();
		//结束正文
		virtual void start_header();
		
		virtual void add_header_line( LPCTSTR szHeaderLine );
};

#endif // !defined(AFX_MAILMESSAGE_H__55DE48CC_BEA4_11D1_870E_444553540000__INCLUDED_)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?