74 lines
1.9 KiB
C++
74 lines
1.9 KiB
C++
#include "StdAfx.h"
|
|
#include ".\outlookmng.h"
|
|
|
|
COutlookMng::COutlookMng(void)
|
|
{
|
|
}
|
|
|
|
COutlookMng::~COutlookMng(void)
|
|
{
|
|
}
|
|
|
|
BOOL COutlookMng::Init(void)
|
|
{
|
|
//ol은 OutLook의 약자
|
|
COleException e;
|
|
if(m_appOutLook.m_lpDispatch == NULL)
|
|
m_appOutLook.CreateDispatch("Outlook.Application", &e);
|
|
|
|
m_vecAddress.clear();
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL COutlookMng::SendMail(CString strTitle, CString strFilePath, CString strFileName)
|
|
{
|
|
CNameSpace olNs(m_appOutLook.GetNamespace("MAPI"));
|
|
COleVariant ovOptional(DISP_E_PARAMNOTFOUND, VT_ERROR);
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
olNs.Logon(ovOptional, ovOptional, ovOptional, ovOptional);
|
|
|
|
CMailItem mail(m_appOutLook.CreateItem(0));
|
|
|
|
mail.put_Subject(strTitle);
|
|
mail.put_Body(strTitle);
|
|
|
|
/************************************************************************/
|
|
/* 보낼사람들 주소 설정 */
|
|
/************************************************************************/
|
|
CRecipients recipients;
|
|
recipients = mail.get_Recipients();
|
|
int nSize = (int)m_vecAddress.size();
|
|
for(int i = 0 ; i < nSize; i++)
|
|
{
|
|
CString strAddr = m_vecAddress[i];
|
|
recipients.Add(strAddr);
|
|
}
|
|
|
|
recipients.ResolveAll();
|
|
|
|
/************************************************************************/
|
|
/* 첨부파일 설정 */
|
|
/************************************************************************/
|
|
CAttachments atts;
|
|
atts = mail.get_Attachments();
|
|
COleVariant path(strFilePath);
|
|
COleVariant name(strFileName);
|
|
COleVariant v1("1");
|
|
COleVariant v2("15000");
|
|
atts.Add(path, v1, v2, name);
|
|
mail.Send();
|
|
|
|
olNs.Logoff();
|
|
//////////////////////////////////////////////////////////////////////////
|
|
AfxMessageBox("파일전송이 완료되었습니다.");
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL COutlookMng::InsertAddress(CString strAddress)
|
|
{
|
|
m_vecAddress.push_back(strAddress);
|
|
return TRUE;
|
|
}
|