2010发邮件附件收到乱码。
String filename = L"E:\\附件\\2.txt"; //需要添加的附件文件 IdMessage1-> MessageParts-> Add(); new TIdAttachmentFile(IdMessage1-> MessageParts,filename); IdMessage1->MessageParts->Items[0]->FileName = L"=?gbk?B?" + ExtractFileName( filename) + L"?=";
IdSMTP1->Username ="zzbinfo"; IdSMTP1->Password ="2629339zzb"; IdSMTP1->Host ="smtp.163.com"; IdSMTP1->Port =25; IdMessage1->Body->Clear(); IdMessage1->Encoding = meMIME; IdMessage1->ContentType = "multipart/alternative";//"text/html"; IdMessage1->ContentTransferEncoding="base64"; IdMessage1->CharSet="utf-8"; IdMessage1->Subject="测试"; IdMessage1->Body->Text ="This is a text!!!"; IdMessage1->From->Text="zzbinfo@163.com"; IdMessage1->Recipients->EMailAddresses="6171153@qq.com"; String filename = L"c:\\test.txt"; //需要添加的附件文件 IdMessage1-> MessageParts-> Add(); TIdAttachmentFile *AttachEmail = new TIdAttachmentFile(IdMessage1-> MessageParts,filename); AttachEmail->ContentType="application/octet-stream"; AttachEmail->ContentDisposition="attachment"; AttachEmail->ContentTransfer="base64"; AttachEmail->FileName=ExtractFileName(filename); try{ IdSMTP1->Connect(); IdSMTP1->Authenticate(); IdSMTP1->Send(IdMessage1); } catch(...) { ShowMessage("发送失败!"); return; } ShowMessage("发送成功!");}