M
me555555
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Button1Click(Sender: TObject);
begin
with IdMessage1 do
begin
Clear;
Body.Assign(Memo1.Lines);//内容
From.Text := FromText.Text ;//发件人
Recipients.EMailAddresses := EMailAddEdit.text;//收件人
Subject := SubjectEdit.Text ;//主题
if Recet.Checked then //回执
ReceiptRecipient.Text := From.Text
else ReceiptRecipient.Text := '';
end;
TIdAttachment.Create(IdMessage1.MessageParts, Edit1.Text);//附件
if not AuthenType.Checked then //认证
IdSMTP1.AuthenticationType := atNone
else begin
IdSMTP1.AuthenticationType := atLogin;
IdSMTP1.Username := Username.Text ;
IdSMTP1.Password := Password.Text ;
end;
IdSMTP1.Host := Host.Text ;//发送服务器
IdSMTP1.Port := 25;//端口
try
IdSMTP1.Connect;
try
IdSMTP1.Send(IdMessage1);
ShowMessage('E-Mail 成功发出');
finally
IdSMTP1.Disconnect;
end;
except
ShowMessage('E-Mail 发送失敗');
end;
end;
begin
with IdMessage1 do
begin
Clear;
Body.Assign(Memo1.Lines);//内容
From.Text := FromText.Text ;//发件人
Recipients.EMailAddresses := EMailAddEdit.text;//收件人
Subject := SubjectEdit.Text ;//主题
if Recet.Checked then //回执
ReceiptRecipient.Text := From.Text
else ReceiptRecipient.Text := '';
end;
TIdAttachment.Create(IdMessage1.MessageParts, Edit1.Text);//附件
if not AuthenType.Checked then //认证
IdSMTP1.AuthenticationType := atNone
else begin
IdSMTP1.AuthenticationType := atLogin;
IdSMTP1.Username := Username.Text ;
IdSMTP1.Password := Password.Text ;
end;
IdSMTP1.Host := Host.Text ;//发送服务器
IdSMTP1.Port := 25;//端口
try
IdSMTP1.Connect;
try
IdSMTP1.Send(IdMessage1);
ShowMessage('E-Mail 成功发出');
finally
IdSMTP1.Disconnect;
end;
except
ShowMessage('E-Mail 发送失敗');
end;
end;