我想附帶的MemoryStream發送電子郵件,但我總是得到了在我收到的電子郵件,不帶附件此消息「這是MIME格式的多部分消息......」與MemoryStream的發送電子郵件附
代碼:
var
MemStrm : TMemoryStream;
begin
MemStrm := TMemoryStream.Create;
Str1.SaveToStream(MemStrm);
MemStrm.Position := 0;
try
with IdSSLIOHandlerSocketOpenSSL1 do
begin
Destination := 'smtp.mail.yahoo.com' + ':' + IntToStr(465);
Host := 'smtp.mail.yahoo.com';
MaxLineAction := maException;
Port := 465;
SSLOptions.Method := sslvTLSv1;
SSLOptions.Mode := sslmUnassigned;
SSLOptions.VerifyMode := [];
SSLOptions.VerifyDepth := 0;
end;
with IdSMTP1 do
begin
IOHandler := IdSSLIOHandlerSocketOpenSSL1;
Host := 'smtp.mail.yahoo.com';
Port := 465;
AuthType := satDefault;
Password := 'password';
Username := '[email protected]';
UseTLS := utUseImplicitTLS;
end;
with IdMessage1 do
begin
From.Address := '[email protected]';
List:= Recipients.Add;
List.Address:= '[email protected]';
Recipients.EMailAddresses := '[email protected]';
Subject := 'test';
Body.Text := 'test';
ContentType := 'text/plain';
IdAttachment := TIdAttachmentMemory.Create(IdMessage1.MessageParts,MemStrm);
IdAttachment.ContentType := 'text/plain';
IdAttachment.FileName := 'attached.txt';
end;
finally
idsmtp1.Connect;
idsmtp1.Send(idmessage1);
idsmtp1.Disconnect;
MemStrm.Free;
end;
end
我不想將其保存爲文件第一然後安裝它,我怎麼重視樣本的MemoryStream到我的郵箱?
編輯:它沒有與TIdAttachmentFile甚至工作,我使用Indy10版本10.6.0.5049德爾福7
哪個版本的Indy是:請使用
Recipients.Add.Address
或Recipients.EMailAddresses
,不都使用? (當前是10.6.1 iirc) – mjndelphi 7 indy10版本10.6.0.5049,只是更新了我的問題,即使使用TIdAttachmentFile也是如此,同樣的問題。 – user3533628