⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mapimessage.h

📁 A (hopefully) complete extended MAPI wrapper for WinXP, WinCE, and .NET.
💻 H
字号:
#ifndef __MAPIMESSAGE_H__
#define __MAPIMESSAGE_H__

////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// File: MAPIMessage.h
// Description: MAPI Message class wrapper
//
// Copyright (C) 2005-2006, Noel Dillabough
//
// This source code is free to use and modify provided this notice remains intact and that any enhancements
// or bug fixes are posted to the CodeProject page hosting this class for the community to benefit.
//
// Usage: see the Codeproject article at http://www.codeproject.com/internet/CMapiEx.asp
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////

class CMAPIEx;

/////////////////////////////////////////////////////////////
// CMAPIMessage

class AFX_EXT_CLASS CMAPIMessage : public CObject
{
public:
	CMAPIMessage();
	CMAPIMessage(CMAPIMessage& message);
	~CMAPIMessage();

// Attributes
protected:
	CString m_strSenderName;
	CString m_strSenderEmail;
	CString m_strSubject;
	CString m_strBody;
	CString m_strRTF;
	int m_nAttachments;
	CTime m_tmReceived;

	CMAPIEx* m_pMAPI;
	LPMESSAGE m_pMessage;
	DWORD m_dwMessageFlags;
	SBinary m_entry;

// Operations
public:
	void SetEntryID(SBinary* pEntry=NULL);
	SBinary* GetEntryID() { return &m_entry; }

	BOOL IsUnread() { return !(m_dwMessageFlags&MSGFLAG_READ); }
	void MarkAsRead(BOOL bRead=TRUE);
	BOOL Open(CMAPIEx* pMAPI,SBinary entry,DWORD dwMessageFlags);
	void Close();
	BOOL Create(CMAPIEx* pMAPI,int nPriority=IMPORTANCE_NORMAL); // IMPORTANCE_HIGH or IMPORTANCE_LOW also valid

	LPCTSTR GetSenderName() { return m_strSenderName; }
	LPCTSTR GetSenderEmail() { return m_strSenderEmail; }
	LPCTSTR GetSubject() { return m_strSubject; }
	LPCTSTR GetBody();
	LPCTSTR GetRTF();
	CTime& GetReceivedTime() { return m_tmReceived; }
	LPCTSTR GetReceivedTime(LPCTSTR szFormat); // set to NULL for default of "%m/%d/%Y %I:%M %p"

	int GetAttachmentCount() { return m_nAttachments; }
	LPCTSTR GetAttachmentName(int nIndex);
	BOOL SaveAttachments(LPCTSTR szFolder,int nIndex=-1);
	BOOL DeleteAttachments(int nIndex=-1);

	void SetMessageStatus(int nMessageStatus); // used only by WinCE, pass in MSGSTATUS_RECTYPE_SMS to send an SMS
	BOOL AddRecipient(LPCTSTR szEmail,int nType=MAPI_TO);  // MAPI_CC and MAPI_BCC also valid
	void SetSubject(LPCTSTR szSubject);
	void SetSenderName(LPCTSTR szSenderName);
	void SetSenderEmail(LPCTSTR szSenderEmail);
	void SetBody(LPCTSTR szBody);
	void SetRTF(LPCTSTR szRTF);
	BOOL AddAttachment(LPCTSTR szPath,LPCTSTR szName=NULL);
	void SetReadReceipt(BOOL bSet=TRUE,LPCTSTR szReceiverEmail=NULL);
	void MarkAsPrivate();
	BOOL Send();

	// does not copy/reference m_pMessage, shallow copy only
	CMAPIMessage& operator=(CMAPIMessage& message);

	// compares entryID only
	BOOL operator==(CMAPIMessage& message);

protected:
	HRESULT GetProperty(ULONG ulProperty, LPSPropValue &prop);

	void FillSenderName();
	void FillSenderEmail();
	void FillSubject();
	void FillBody();
	void FillRTF();
	void FillAttachmentCount();
	void FillReceivedTime();

	BOOL SaveAttachment(LPATTACH pAttachment,LPCTSTR szPath);
};

#endif

⌨️ 快捷键说明

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