MailMessage.h
上传用户:weimei12
上传日期:2022-08-11
资源大小:185k
文件大小:4k
- #pragma once
- /********************************************************************
- created: 2008:10:24 11:16
- author: 李欣
- filename: c:MyProjectSimpleMailSimpleMailMailMessage.h
- classname: CMailMessage
- purpose: Format a mail comply to RFC 822
- *********************************************************************/
- class CMailMessage
- {
- public:
- CMailMessage();
- virtual ~CMailMessage();
- enum RECIPIENTS_TYPE {TO, CC, BCC};
- ///<summary>
- /// Add a recipient's information
- ///</summary>
- BOOL AddRecipient(IN const CString& strEmailAddress,
- IN const CString& strFriendlyName = _T(""),
- IN RECIPIENTS_TYPE type = TO);
-
- ///<summary>
- /// Get a recipient's information
- ///</summary>
- ///<param name = >
- /// the index of the recipient in the arrary
- ///</param>
- BOOL GetRecipient(OUT CString& strEmailAddress,
- OUT CString& strFriendlyName,
- IN const int nIndex = 0,
- IN const RECIPIENTS_TYPE type = TO);
-
- ///<summary>
- /// Get the count of recipients
- ///</summary>
- int GetNumRecipients(IN const RECIPIENTS_TYPE type = TO);
-
- ///<summary>
- /// Add multiple recipients's information which is mixed together
- ///</summary>
- ///<param name = szRecipients>
- /// the string containing the recipients
- ///</param>
- BOOL AddMultipleRecipients(IN LPCTSTR szRecipients, IN RECIPIENTS_TYPE type = TO);
-
- ///<summary>
- /// get and set chars per line
- ///</summary>
- UINT GetCharsPerLine();
- void SetCharsPerLine(IN UINT nCharsPerLine);
- ///<summary>
- /// set the related inforamtion
- ///</summary>
- void SetInfo(IN const CString& strFrom, IN const CString& strSubject, IN const CString& strBody,
- IN const CString& strUsername, IN const CString& strPassword);
- ///<summary>
- /// get the mail's body
- ///</summary>
- CString GetMailBody();
- ///<summary>
- /// get the mail's header
- ///</summary>
- CString GetMailHeader();
- ///<summary>
- /// format the mail' header without any encoding mechanism
- ///</summary>
- void FormatMessage();
-
- protected:
- ///<summary>
- /// add a line into the mail's header
- ///</summary>
- void AddHeaderLine(IN const CString& strHeaderLine);
- // When overriding prepare_header(), call base class
- // version first, then add specialized
- // add_header_line calls.
- // This ensures that the base class has a chance to
- // create the header lines it needs.
- ///<summary>
- /// format the pure header
- ///</summary>
- virtual void PrepareHeader();
- ///<summary>
- /// do some jobs if necessary
- ///</summary>
- virtual void PrepareBody();
- ///<summary>
- /// the sender address
- ///</summary>
- CString m_strFrom;
- ///<summary>
- /// the letter's subject
- ///</summary>
- CString m_strSubject;
- ///<summary>
- /// the user name
- ///</summary>
- CString m_strUsername;
- ///<summary>
- /// the password
- ///</summary>
- CString m_strPassword;
- ///<summary>
- /// the letter's content
- ///</summary>
- CString m_strBody;
- ///<summary>
- /// the mail's header
- ///</summary>
- CString m_strHeader;
- CTime m_tDateTime;
- private:
- ///<summary>
- /// chars per line
- ///</summary>
- UINT m_nCharsPerLine;
- class CRecipient
- {
- public:
- CString m_strEmailAddress;
- CString m_strFriendlyName;
- };
- ///<summary>
- /// the primary recipients
- ///</summary>
- CArray <CRecipient, CRecipient&> m_Recipients;
- ///<summary>
- /// the secondary recipients
- ///</summary>
- CArray <CRecipient, CRecipient&> m_CCRecipients;
- ///<summary>
- /// additional recipients
- ///</summary>
- CArray <CRecipient, CRecipient&> m_BCCRecipients;
-
- };