MailManager.cpp
上传用户:weimei12
上传日期:2022-08-11
资源大小:185k
文件大小:4k
- #include "StdAfx.h"
- #include "SimpleMail.h"
- #include "MailMessage.h"
- #include "SmtpSendManger.h"
- #include "Pop3Message.h"
- #include "MailSaveMngr.h"
- #include "RecvProgressDlg.h"
- #include "PopReceiveManager.h"
- #include "MailManager.h"
- CMailManager::CMailManager(void)
- {
- }
- CMailManager::~CMailManager(void)
- {
- }
- ///<summary>
- /// send a mail
- ///</summary>
- HRESULT CMailManager::SendMailMessage(const CString& strRcs,
- const CString& strCCRcs,
- const CString& strBCCRcs,
- const CString& strSubject,
- const CString& strContent,
- const CStringArray& strAttachFiles)
- {
- if (m_cSendMngr.SendMailMessage(strRcs, strCCRcs,
- strBCCRcs, strSubject,
- strContent, strAttachFiles) != HRESULT_SUCCESS)
- {
- return HRESULT_FAIL;
- }
- return HRESULT_SUCCESS;
- }
- ///<summary>
- /// receive the mails
- ///</summary>
- HRESULT CMailManager::RecMail(CRecvProgressDlg* pProgressDlg, CArray<MAILPOS>& arrPos, CArray<UINT>& arrSize)
- {
- if (m_cReceiveMngr.RecMail(&m_cSaveMngr, pProgressDlg, arrPos, arrSize) != HRESULT_SUCCESS)
- {
- return HRESULT_FAIL;
- }
- return HRESULT_SUCCESS;
- }
- ///<summary>
- /// delete the specified mail
- ///</summary>
- HRESULT CMailManager::DelMail(const CArray<UINT>& arrIndex)
- {
- if (m_cReceiveMngr.DelMail(arrIndex) != HRESULT_SUCCESS)
- {
- return HRESULT_FAIL;
- }
- return HRESULT_SUCCESS;
- }
- ///<summary>
- /// get the user name
- ///</summary>
- CString CMailManager::GetUserName()
- {
- return m_strUserName;
- }
- ///<summary>
- /// set the user name
- ///</summary>
- void CMailManager::SetUserName(const CString& strUserName)
- {
- m_strUserName = strUserName;
- m_cSendMngr.SetUserName(strUserName);
- m_cReceiveMngr.SetUserName(strUserName);
- }
- ///<summary>
- /// get the password
- ///</summary>
- CString CMailManager::GetPassword()
- {
- return m_strPassword;
- }
- ///<summary>
- /// set the password
- ///</summary>
- void CMailManager::SetPassword(const CString& strPassword)
- {
- m_strPassword = strPassword;
- m_cSendMngr.SetPassword(strPassword);
- m_cReceiveMngr.SetPassword(strPassword);
- }
- ///<summary>
- /// get the smtp server address
- ///</summary>
- CString CMailManager::GetSmtpServer()
- {
- return m_strSmtpServer;
- }
- ///<summary>
- /// set the smtp server address
- ///</summary>
- void CMailManager::SetSmtpServer(const CString& strSmtpServer)
- {
- m_strSmtpServer = strSmtpServer;
- m_cSendMngr.SetSmtpServer(strSmtpServer);
- }
- ///<summary>
- /// get the pop3 server address
- ///</summary>
- CString CMailManager::GetPopServer()
- {
- return m_strPopServer;
- }
- ///<summary>
- /// set the pop3 server address
- ///</summary>
- void CMailManager::SetPopServer(const CString& strPopServer)
- {
- m_strPopServer = strPopServer;
- m_cReceiveMngr.SetPopServer(strPopServer);
- }
- ///<summary>
- /// get the sender address
- ///</summary>
- CString CMailManager::GetSendMail()
- {
- return m_strSendMail;
- }
- ///<summary>
- /// set the sender address
- ///</summary>
- void CMailManager::SetSendMail(const CString& strSendMail)
- {
- m_strSendMail = strSendMail;
- m_cSendMngr.SetSendMail(strSendMail);
- }
- ///<summary>
- /// get the setting whether to validate the identity
- ///</summary>
- BOOL CMailManager::GetValidate()
- {
- return m_bValidate;
- }
- ///<summary>
- /// set whether to validate the identity
- ///</summary>
- void CMailManager::SetValidate(IN BOOL bValidate)
- {
- m_bValidate = bValidate;
- m_cSendMngr.SetValidate(bValidate);
- }
- ///<summary>
- /// get the manager for saving mails
- ///</summary>
- CMailSaveMngr* CMailManager::GetSaveMngr()
- {
- return &m_cSaveMngr;
- }