MIMEMessage.h
上传用户:weimei12
上传日期:2022-08-11
资源大小:185k
文件大小:3k
- #pragma once
- /********************************************************************
- created: 2008:10:24 17:48
- author: 李欣
- filename: c:MyProjectSimpleMailSimpleMailMIMEMessage.h
- classname: CMIMEMessage
- purpose: Formats a message using the MIME specification.
- *********************************************************************/
- class CMIMEMessage : public CMailMessage
- {
- public:
- CMIMEMessage();
- virtual ~CMIMEMessage();
- enum eMIMETypeCode
- {
- TEXT_PLAIN = 0,
- APPLICATION_OCTETSTREAM,
- NEXT_FREE_MIME_CODE
- };
- enum eMIMEEncodingCode
- {
- _7BIT = 0,
- _8BIT,
- BINARY,
- QUOTED_PRINTABLE,
- BASE64,
- NEXT_FREE_ENCODING_CODE
- };
- ///<summary>
- /// add the part to the part-list used to build the body.
- ///</summary>
- ///<param name = szContent>
- /// the content of this mime part
- ///</param>
- ///<param name = nContentType>
- /// the MIME type
- ///</param>
- ///<param name = szParameters>
- /// parameters needed by some mime types
- ///</param>
- ///<param name = nEncoding>
- /// the encoding type
- ///</param>
- ///<param name = bPath>
- /// whether szContent is a path
- ///</param>
- BOOL AddMIMEPart(IN LPCTSTR szContent,
- IN const int nContentType = APPLICATION_OCTETSTREAM,
- IN LPCTSTR szParameters = _T(""),
- IN const int nEncoding = BASE64,
- IN const BOOL bPath = TRUE);
- protected:
- ///<summary>
- /// format the pure header
- ///</summary>
- virtual void PrepareHeader();
- ///<summary>
- /// do some jobs if necessary
- ///</summary>
- virtual void PrepareBody();
- ///<summary>
- /// Insert the boundary part at the end
- ///</summary>
- void InsertMessageEnd(INOUT CString& strText);
- ///<summary>
- /// Insert the boundary part
- ///</summary>
- void InsertBoundary(INOUT CString& strText);
- ///<summary>
- /// register one mime type content into the manager
- ///</summary>
- void RegisterMimeType(IN CMIMEContentAgent* pMIMEType);
- ///<summary>
- /// Append each mime part to the body
- ///</summary>
- virtual void AppendMimeParts();
-
- ///<summary>
- /// the comment
- ///</summary>
- CString m_strNoMIMEText;
- ///<summary>
- /// the boundary string
- ///</summary>
- CString m_strPartBoundary;
- ///<summary>
- /// the type of the mail
- ///</summary>
- CString m_strMIMEContentType;
- private:
- ///<summary>
- /// the related information about one part of the body
- ///</summary>
- class CMIMEPart
- {
- public:
- int m_nEncoding;//the encoding type
- int m_nContentType;//the content type
- CString m_strParameters;//any parameters of this field
- BOOL m_bPath;//whether is a path
- CString m_strContent;//the content
- };
- ///<summary>
- /// the list of different type parts
- ///</summary>
- CList <CMIMEPart, CMIMEPart&> m_MIMEPartList;
- ///<summary>
- /// the manager of the mime type
- ///</summary>
- class CMIMETypeManager
- {
- public:
- CMIMETypeManager();
- virtual ~CMIMETypeManager();
-
- ///<summary>
- /// Get the specified type handler
- ///</summary>
- CMIMEContentAgent* GetHandler(IN const int nContentType);
- ///<summary>
- /// register one mime type content into the manager
- ///</summary>
- void RegisterMIMEType(IN CMIMEContentAgent* pMIMEType);
-
- private:
- CCriticalSection m_csAccess;
- ///<summary>
- /// the list to store different type parts
- ///</summary>
- CList <CMIMEContentAgent*, CMIMEContentAgent*> m_MIMETypeList;
- };
- static CMIMETypeManager m_MIMETypeManager;
- };