1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2013, 2015 - TortoiseGit
4 // Copyright (C) 2011-2013 Sven Strickroth <email@cs-ware.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "SendMailPatch.h"
23 #include "SerialPatch.h"
25 CSendMailPatch::CSendMailPatch(const CString
& To
, const CString
& CC
, const CString
& subject
, bool bAttachment
, bool bCombine
)
26 : CSendMailCombineable(To
, CC
, subject
, bAttachment
, bCombine
)
30 CSendMailPatch::~CSendMailPatch()
34 int CSendMailPatch::SendAsSingleMail(const CTGitPath
& path
, CGitProgressList
* instance
)
38 CString
pathfile(path
.GetWinPathString());
40 if (patch
.Parse(pathfile
, !m_bAttachment
))
42 instance
->ReportError(_T("Could not open/parse ") + pathfile
);
47 CStringArray attachments
;
49 attachments
.Add(pathfile
);
51 body
= patch
.m_strBody
;
53 return SendMail(path
, instance
, m_sSenderName
, m_sSenderMail
, m_sTo
, m_sCC
, patch
.m_Subject
, body
, attachments
);
56 int CSendMailPatch::SendAsCombinedMail(const CTGitPathList
&list
, CGitProgressList
* instance
)
60 CStringArray attachments
;
62 for (int i
= 0; i
< list
.GetCount(); ++i
)
65 if (patch
.Parse((CString
&)list
[i
].GetWinPathString(), !m_bAttachment
))
67 instance
->ReportError(_T("Could not open/parse ") + list
[i
].GetWinPathString());
72 attachments
.Add(list
[i
].GetWinPathString());
73 body
+= patch
.m_Subject
;
80 CGit::StringAppend(&body
, (BYTE
*)(LPCSTR
)patch
.m_Body
, CP_UTF8
, patch
.m_Body
.GetLength());
82 catch (CMemoryException
*)
84 instance
->ReportError(_T("Out of memory. Could not parse ") + list
[i
].GetWinPathString());
89 return SendMail(CTGitPath(), instance
, m_sSenderName
, m_sSenderMail
, m_sTo
, m_sCC
, m_sSubject
, body
, attachments
);