G
GAOGAIGAR
Unregistered / Unconfirmed
GUEST, unregistred user!
当邮件的附件比较大时,总是发送了一点就自动断开smtp服务器了,有没有办法让连接时间延长或在发送完邮件前不断开smtp服务器
发送部分的代码
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
Memo1.Clear;
smtp.Host:= smtpHost.Text;
SMTP.AuthType:=atDefault;
SMTP.Username:=usename.Text;
SMTP.Password:= usepass.Text;
MailMessage.From.Address := MailFrom.Text;
MailMessage.Recipients.EMailAddresses := MailAddress.Text;
MailMessage.Subject := Subject.Text;
MailMessage.Body.Text := Body.Text;
MailMessage.CharSet := 'gb2312';
MailMessage.Body.Assign(Body.Lines);
if FileExists(FileAddress.Text) then
TIdAttachmentFile.Create(MailMessage.MessageParts,FileAddress.Text);
try
try
SMTP.Connect;
SMTP.Send(MailMessage);
except on E:Exception do
Memo1.Lines.Insert(0, 'ERROR: ' + E.Message);
end;
finally
if SMTP.Connected then
SMTP.Disconnect;
end;
end;
发送部分的代码
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
Memo1.Clear;
smtp.Host:= smtpHost.Text;
SMTP.AuthType:=atDefault;
SMTP.Username:=usename.Text;
SMTP.Password:= usepass.Text;
MailMessage.From.Address := MailFrom.Text;
MailMessage.Recipients.EMailAddresses := MailAddress.Text;
MailMessage.Subject := Subject.Text;
MailMessage.Body.Text := Body.Text;
MailMessage.CharSet := 'gb2312';
MailMessage.Body.Assign(Body.Lines);
if FileExists(FileAddress.Text) then
TIdAttachmentFile.Create(MailMessage.MessageParts,FileAddress.Text);
try
try
SMTP.Connect;
SMTP.Send(MailMessage);
except on E:Exception do
Memo1.Lines.Insert(0, 'ERROR: ' + E.Message);
end;
finally
if SMTP.Connected then
SMTP.Disconnect;
end;
end;