写了一个自动定时发送邮件的控制台工具,工具在windows环境下发送邮件没问题,但是在linux环境下的就会出现主题为中文时就会乱码,但正文里中文没有问题。有人遇到过吗? 代码: function SendHtmlMail(SubjectStr, BodyStr: String): Boolean; begin Result := False; with IdMessage do begin MessageParts.Clear; Subject:=SubjectStr; CharSet := 'UTF-8'; ContentType := 'multipart/alternative;type="text/html"'; ContentTransferEncoding:='base64'; end; with TIdText.Create(IdMessage.MessageParts, nil) do begin Body.Text := BodyStr; Body.Add('<p>保密:本函件仅供指定的接收者阅读,其中可能包含特许和机密的信息,非指定接收者不得复印、散发或根据此邮件采取任何行动。若此邮件系误传,请立即联系发件人并予以销毁为宜 </p>'); CharSet := 'UTF-8'; ContentType := 'text/html'; ContentTransfer:='base64'; end;
try try IdSMTP.Connect; if IdSMTP.Authenticate then begin IdSMTP.Send(IdMessage); Result := True; end; except on E: Exception do begin Log.WriteLog(E.Message, 3); end; end; finally IdSMTP.Disconnect; end; end;
----------------------------------------------
96年开始用delphi3,用到现在变delphi xe3了,MIS,ERP,HRM,Mssql,Mysql...