StrCmd=szdate;//date
StrCmd +="From:" + szFrom + "\ r \ n";
SzTo strCmd +=", "+ +" \ r \ n ";
StrCmd +="Subject:" + szsubject + "\ r \ n";
StrCmd +="Mime - Version: 1.0 \ r \ n";
StrCmd +="content-type: multipart/mixed; The \ r \ n ";
//note above these strings before does not have space to the top to the
StrCmd +="is a boundary=" __=_Part_Boundary_001_011991. 029871 \ \ r \ n \ r \ n ";//this must keep one or more Spaces in front of the
StrCmd +="-- __=_Part_Boundary_001_011991. 029871 \ r \ n";
StrCmd +="Content - Description: enclosed photo \ r \ n";
StrCmd +="content-type: text/plain. The \ r \ n ";
//in front of the roof to the
StrCmd +="charset=" gb2312 \ \ r \ n ";//in front of the empty one can at least know need a space between the parameters and the front type of
StrCmd +="Content - Transfer - Encoding: base64 \ r \ n \ r \ n";
StrCmd +=Base64Encode (mailContent c_str ()) + "\ r \ n \ r \ n";//email content
StrCmd +="-- __=_Part_Boundary_001_011991. 029871 \ r \ n";
StrCmd +="content-type: PNG image/PNG; The \ r \ n ";
//the above to
Printf (" filename==========");
Const char * pszName=: : STRRCHR (" c: "(pszFilename, '\ \');
if (! PszName)
PszName=pszFilename;
The else
PszName++;
Filename=pszName;
Cout
StrCmd +="Content - Transfer - Encoding: base64 \ r \ n \ r \ n";
Send (sockfd, strCmd c_str (), strCmd. The length (), 0).
//strCmd. Delete (0, strCmd. Length ());
//strCmd +=fileDate + "\ r \ n \ r \ n";//file binary encoding data into base64
/* multiple attachments transmitted
StrCmd +="-- __=_Part_Boundary_001_011991. 029871 \ r \ n";
StrCmd +="content-type: application/octet - stream; The \ r \ n ";
StrCmd +="name=" + filename + "\ r \ n";//in the same way at least one empty
StrCmd +="Content - Transfer - Encoding: base64 \ r \ n \ r \ n";
StrCmd +=fileDate + "\ r \ n \ r \ n";//file binary encoding data into base64
*/
//send the body
Printf (" is read the file... \n");
If (ReadFromFile (pszFilename, filename, sockfd)==false)
{
Printf (" file read failure \ n ");
return ;
}
String strCmd1;
StrCmd1 +="\ r \ n \ r \ n - (=_Part_Boundary_001_011991. 029871 - \ r \ n";
StrCmd1 +="\ r \ n \ r \ n";
//end. Note here to multiple blank lines
//the above string together good sent to the server can
Send (sockfd, strCmd1 c_str (), strCmd1. The length (), 0).
Memset (buff, 0, sizeof (buff));
Recv (sockfd, buff, sizeof (buff), 0).
Printf (" send success! \ n ");
return ;
}