5 #include "unicodeutils.h"
22 void CPatch::ConvertToArray(CString
&to
,CStringArray
&Array
)
27 CString str
=to
.Tokenize(_T(";"),start
);
33 int CPatch::Send(CString
&pathfile
,CString
&TO
,CString
&CC
,bool bAttachment
, bool useMAPI
)
35 if(this->Parser(pathfile
) )
38 CStringArray attachments
;
41 attachments
.Add(pathfile
);
45 sender
.Format(_T("%s <%s> "),g_Git
.GetUserName(),g_Git
.GetUserEmail());
50 BOOL bMAPIInit
= mapiSender
.MAPIInitialize();
53 m_LastError
= mapiSender
.GetLastErrorMsg();
57 mapiSender
.SetShowComposeDialog(TRUE
);
58 mapiSender
.SetFrom(g_Git
.GetUserEmail());
60 mapiSender
.SetSubject(m_Subject
);
61 mapiSender
.SetMessage(m_strBody
);
63 mapiSender
.AddAttachment(pathfile
);
65 BOOL bSend
= mapiSender
.Send();
70 m_LastError
= mapiSender
.GetLastErrorMsg();
77 if(mail
.SendSpeedEmail(this->m_Author
,TO
,this->m_Subject
,this->m_strBody
,NULL
,&attachments
,CC
,25,sender
))
81 this->m_LastError
=mail
.GetLastErrorText();
86 CRegString
server(REG_SMTP_SERVER
);
87 CRegDWORD
port(REG_SMTP_PORT
,25);
88 CRegDWORD
bAuth(REG_SMTP_ISAUTH
);
89 CRegString
user(REG_SMTP_USER
);
90 CRegString
password(REG_SMTP_PASSWORD
);
92 mail
.SetSMTPServer(CUnicodeUtils::GetUTF8(server
),port
);
94 AddRecipient(mail
,TO
,false);
95 AddRecipient(mail
,CC
,true);
98 mail
.AddAttachment(CUnicodeUtils::GetUTF8(pathfile
));
100 CString name
,address
;
101 GetNameAddress(this->m_Author
,name
,address
);
102 mail
.SetSenderName(CUnicodeUtils::GetUTF8(name
));
103 mail
.SetSenderMail(CUnicodeUtils::GetUTF8(address
));
105 mail
.SetXPriority(XPRIORITY_NORMAL
);
106 mail
.SetXMailer("The Bat! (v3.02) Professional");
108 mail
.SetSubject(CUnicodeUtils::GetUTF8(this->m_Subject
));
110 mail
.SetMessageBody((char*)&this->m_Body
[0]);
114 mail
.SetLogin(CUnicodeUtils::GetUTF8((CString
&)user
));
115 mail
.SetPassword(CUnicodeUtils::GetUTF8((CString
&)password
));
123 int CPatch::Send(CTGitPathList
&list
,CString
&To
,CString
&CC
, CString
&subject
,bool bAttachment
, bool useMAPI
,CString
*errortext
)
125 CStringArray attachments
;
127 for(int i
=0;i
<list
.GetCount();i
++)
130 patch
.Parser((CString
&)list
[i
].GetWinPathString());
133 attachments
.Add(list
[i
].GetWinPathString());
134 body
+=patch
.m_Subject
;
139 g_Git
.StringAppend(&body
,(BYTE
*)patch
.m_Body
.GetBuffer(),CP_ACP
,patch
.m_Body
.GetLength());
145 sender
.Format(_T("%s <%s> "),g_Git
.GetUserName(),g_Git
.GetUserEmail());
150 BOOL bMAPIInit
= mapiSender
.MAPIInitialize();
154 *errortext
= mapiSender
.GetLastErrorMsg();
158 mapiSender
.SetShowComposeDialog(TRUE
);
159 mapiSender
.SetFrom(g_Git
.GetUserEmail());
160 mapiSender
.SetTo(To
);
161 mapiSender
.SetSubject(subject
);
162 mapiSender
.SetMessage(body
);
163 for(int i
=0; i
< attachments
.GetSize(); i
++)
165 mapiSender
.AddAttachment(attachments
[i
]);
168 BOOL bSend
= mapiSender
.Send();
174 *errortext
= mapiSender
.GetLastErrorMsg();
181 if(mail
.SendSpeedEmail(sender
,To
,subject
,body
,NULL
,&attachments
,CC
,25,sender
))
186 *errortext
=mail
.GetLastErrorText();
192 int CPatch::Parser(CString
&pathfile
)
199 if( ! PatchFile
.Open(pathfile
,CFile::modeRead
) )
205 { PatchFile
.ReadString(str
);
207 this->m_Author
=str
.Right( str
.GetLength() - 6 );
209 this->m_Date
= str
.Right( str
.GetLength() - 6 );
211 this->m_Subject
= str
.Right( str
.GetLength() - 8 );
216 LONGLONG offset
=PatchFile
.GetPosition();
218 PatchFile
.Read(m_Body
.GetBuffer(PatchFile
.GetLength()),PatchFile
.GetLength());
219 m_Body
.ReleaseBuffer();
224 one
=m_Body
.Tokenize("\n",start
);
226 one
=m_Body
.Tokenize("\n",start
);
227 if(one
.GetLength()>6)
228 g_Git
.StringAppend(&m_Author
,(BYTE
*)one
.GetBuffer()+6,CP_ACP
,one
.GetLength()-6);
230 one
=m_Body
.Tokenize("\n",start
);
231 if(one
.GetLength()>6)
232 g_Git
.StringAppend(&m_Date
,(BYTE
*)one
.GetBuffer()+6,CP_ACP
,one
.GetLength()-6);
234 one
=m_Body
.Tokenize("\n",start
);
235 if(one
.GetLength()>8)
236 g_Git
.StringAppend(&m_Subject
,(BYTE
*)one
.GetBuffer()+8,CP_ACP
,one
.GetLength()-8);
238 //one=m_Body.Tokenize("\n",start);
240 g_Git
.StringAppend(&m_strBody
,(BYTE
*)m_Body
.GetBuffer()+start
+1,CP_ACP
,m_Body
.GetLength()-start
-1);
245 void CPatch::GetNameAddress(CString
&in
, CString
&name
,CString
&address
)
248 start
=in
.Find(_T('<'));
249 end
=in
.Find(_T('>'));
251 if(start
>=0 && end
>=0)
254 address
=in
.Mid(start
+1,end
-start
-1);
260 void CPatch::AddRecipient(CSmtp
&mail
, CString
&tolist
, bool isCC
)
265 CString one
=tolist
.Tokenize(_T(";"),pos
);
266 int start
=one
.Find(_T('<'));
267 int end
= one
.Find(_T('>'));
270 if( start
>=0 && end
>=0)
272 name
=CUnicodeUtils::GetUTF8(one
.Left(start
));
273 address
=CUnicodeUtils::GetUTF8(one
.Mid(start
+1,end
-start
-1));
274 if(address
.IsEmpty())
277 mail
.AddCCRecipient(address
,name
);
279 mail
.AddRecipient(address
,name
);
286 mail
.AddCCRecipient(CUnicodeUtils::GetUTF8(one
));
288 mail
.AddRecipient(CUnicodeUtils::GetUTF8(one
));