Delphi7 TIdSMTP控件发送邮件问题. 如果不添加附件,发出去的邮件正文为空;添加附件之后才显示正文内容
IdMsgSend.Clear;withIdMsgSenddobeginRecipients.EMailAddresses:='123@163.com';//发送到Sub...
IdMsgSend.Clear;
with IdMsgSend do
begin
Recipients.EMailAddresses := '123@163.com'; //发送到
Subject := edtSubject.Text;
Sender.Name := 'admin';
Sender.Address := SendAddress.Text;
From.Name := Sender.Name;
From.Address := Sender.Address;
Body.Assign(MemContent.Lines);//邮件正文
Priority := TIdMessagePriority(4);//优先级
CCList.EMailAddresses := edtCC.Text; //抄送
BccList.EMailAddresses := edtBCC.Text;//暗送
if RzCheckBox1.Checked then
ReceiptRecipient.Text := '123@163.com'
else
ReceiptRecipient.Text := ''; //需要回复
IdMsgSend.IsEncoded := True;
for i := 0 to lvFiles.Items.Count - 1 do
begin
TIdAttachment.Create(IdMsgSend.MessageParts, lvFiles.Items[i].Caption);
end;//附件
end;
SMTP.AuthenticationType := atLogin;
SMTP.Username := SendAddress.Text; //发送人
SMTP.Password := SenderPassword.Text; //密码
SMTP.Host := SmtpServer.Text; //服务器
SMTP.Port := 25;//端口
SMTP.Connect;
try
SMTP.Authenticate;//账号验证
except
SMTP.Disconnect;
Application.MessageBox('用户名和密码不匹配,请检查!', '提示', MB_ICONERROR);
end;
try
SMTP.Send(IdMsgSend);
finally
SMTP.Disconnect;
end; 展开
with IdMsgSend do
begin
Recipients.EMailAddresses := '123@163.com'; //发送到
Subject := edtSubject.Text;
Sender.Name := 'admin';
Sender.Address := SendAddress.Text;
From.Name := Sender.Name;
From.Address := Sender.Address;
Body.Assign(MemContent.Lines);//邮件正文
Priority := TIdMessagePriority(4);//优先级
CCList.EMailAddresses := edtCC.Text; //抄送
BccList.EMailAddresses := edtBCC.Text;//暗送
if RzCheckBox1.Checked then
ReceiptRecipient.Text := '123@163.com'
else
ReceiptRecipient.Text := ''; //需要回复
IdMsgSend.IsEncoded := True;
for i := 0 to lvFiles.Items.Count - 1 do
begin
TIdAttachment.Create(IdMsgSend.MessageParts, lvFiles.Items[i].Caption);
end;//附件
end;
SMTP.AuthenticationType := atLogin;
SMTP.Username := SendAddress.Text; //发送人
SMTP.Password := SenderPassword.Text; //密码
SMTP.Host := SmtpServer.Text; //服务器
SMTP.Port := 25;//端口
SMTP.Connect;
try
SMTP.Authenticate;//账号验证
except
SMTP.Disconnect;
Application.MessageBox('用户名和密码不匹配,请检查!', '提示', MB_ICONERROR);
end;
try
SMTP.Send(IdMsgSend);
finally
SMTP.Disconnect;
end; 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询