4 #include "registry.h"
\r
5 #include "unicodeutils.h"
\r
21 void CPatch::ConvertToArray(CString &to,CStringArray &Array)
\r
26 CString str=to.Tokenize(_T(";"),start);
\r
32 int CPatch::Send(CString &pathfile,CString &TO,CString &CC,bool bAttachment)
\r
35 if(this->Parser(pathfile) )
\r
38 CStringArray attachments,CCArray;
\r
41 attachments.Add(pathfile);
\r
44 //ConvertToArray(CC,CCArray);
\r
47 sender.Format(_T("%s <%s> "),g_Git.GetUserName(),g_Git.GetUserEmail());
\r
49 if(mail.SendSpeedEmail(this->m_Author,TO,this->m_Subject,this->m_strBody,NULL,&attachments,CC,25,sender))
\r
53 this->m_LastError=mail.GetLastErrorText();
\r
57 CRegString server(REG_SMTP_SERVER);
\r
58 CRegDWORD port(REG_SMTP_PORT,25);
\r
59 CRegDWORD bAuth(REG_SMTP_ISAUTH);
\r
60 CRegString user(REG_SMTP_USER);
\r
61 CRegString password(REG_SMTP_PASSWORD);
\r
63 mail.SetSMTPServer(CUnicodeUtils::GetUTF8(server),port);
\r
65 AddRecipient(mail,TO,false);
\r
66 AddRecipient(mail,CC,true);
\r
69 mail.AddAttachment(CUnicodeUtils::GetUTF8(pathfile));
\r
71 CString name,address;
\r
72 GetNameAddress(this->m_Author,name,address);
\r
73 mail.SetSenderName(CUnicodeUtils::GetUTF8(name));
\r
74 mail.SetSenderMail(CUnicodeUtils::GetUTF8(address));
\r
76 mail.SetXPriority(XPRIORITY_NORMAL);
\r
77 mail.SetXMailer("The Bat! (v3.02) Professional");
\r
79 mail.SetSubject(CUnicodeUtils::GetUTF8(this->m_Subject));
\r
81 mail.SetMessageBody((char*)&this->m_Body[0]);
\r
85 mail.SetLogin(CUnicodeUtils::GetUTF8((CString&)user));
\r
86 mail.SetPassword(CUnicodeUtils::GetUTF8((CString&)password));
\r
89 return !mail.Send();
\r
95 int CPatch::Parser(CString &pathfile)
\r
99 CStdioFile PatchFile;
\r
101 m_PathFile=pathfile;
\r
102 if( ! PatchFile.Open(pathfile,CFile::modeRead) )
\r
108 { PatchFile.ReadString(str);
\r
110 this->m_Author=str.Right( str.GetLength() - 6 );
\r
112 this->m_Date = str.Right( str.GetLength() - 6 );
\r
114 this->m_Subject = str.Right( str.GetLength() - 8 );
\r
119 LONGLONG offset=PatchFile.GetPosition();
\r
121 PatchFile.Read(m_Body.GetBufferSetLength(PatchFile.GetLength()),PatchFile.GetLength());
\r
126 one=m_Body.Tokenize("\n",start);
\r
128 one=m_Body.Tokenize("\n",start);
\r
129 if(one.GetLength()>6)
\r
130 g_Git.StringAppend(&m_Author,(BYTE*)one.GetBuffer()+6,CP_ACP,one.GetLength()-6);
\r
132 one=m_Body.Tokenize("\n",start);
\r
133 if(one.GetLength()>6)
\r
134 g_Git.StringAppend(&m_Date,(BYTE*)one.GetBuffer()+6,CP_ACP,one.GetLength()-6);
\r
136 one=m_Body.Tokenize("\n",start);
\r
137 if(one.GetLength()>8)
\r
138 g_Git.StringAppend(&m_Subject,(BYTE*)one.GetBuffer()+8,CP_ACP,one.GetLength()-8);
\r
140 //one=m_Body.Tokenize("\n",start);
\r
142 g_Git.StringAppend(&m_strBody,(BYTE*)m_Body.GetBuffer()+start+1,CP_ACP,m_Body.GetLength()-start-1);
\r
147 void CPatch::GetNameAddress(CString &in, CString &name,CString &address)
\r
150 start=in.Find(_T('<'));
\r
151 end=in.Find(_T('>'));
\r
153 if(start >=0 && end >=0)
\r
155 name=in.Left(start);
\r
156 address=in.Mid(start+1,end-start-1);
\r
162 void CPatch::AddRecipient(CSmtp &mail, CString &tolist, bool isCC)
\r
167 CString one=tolist.Tokenize(_T(";"),pos);
\r
168 int start=one.Find(_T('<'));
\r
169 int end = one.Find(_T('>'));
\r
172 if( start>=0 && end >=0)
\r
174 name=CUnicodeUtils::GetUTF8(one.Left(start));
\r
175 address=CUnicodeUtils::GetUTF8(one.Mid(start+1,end-start-1));
\r
176 if(address.IsEmpty())
\r
179 mail.AddCCRecipient(address,name);
\r
181 mail.AddRecipient(address,name);
\r
188 mail.AddCCRecipient(CUnicodeUtils::GetUTF8(one));
\r
190 mail.AddRecipient(CUnicodeUtils::GetUTF8(one));
\r