5,388
社区成员
发帖
与我相关
我的任务
分享
var TM:TIdMessage;
S1,S2,S3:string;
begin
TM:=TIDMEssage.Create(nil);
With TM do
begin
Body.Assign(Memo22.Lines);
From.address := Combobox23.Text; // 发件人地址
Recipients.EMailAddresses:=Combobox28.Text; // 收件人地址,这里改为你的EMAIL地址
Subject:=Combobox29.Text; // 邮件标题
Priority:=TIDMessagePriority(Combobox26.ItemIndex);
if Edit21.text<>'' then // 附件1
if FileExists(Edit21.Text) then
TIdAttachment.Create(MessageParts,Edit21.Text);
Edit22.Text:=Trim(Edit22.Text); // 附件2
if Edit22.text<>'' then
if FileExists(Edit22.Text) then
TIdAttachment.Create(MessageParts,Edit22.Text);
Edit23.Text:=Trim(Edit23.Text); // 附件3
if Edit23.text<>'' then
if FileExists(Edit23.Text) then
TIdAttachment.Create(MessageParts,Edit23.Text);
end;
case Combobox27.ItemIndex of
0 : IdSMTP1.AuthenticationType:=atLogin; // 需要认证
1 : IdSMTP1.AuthenticationType:=atNone; // 无需认证
end;
IdSMTP1.Username := Combobox23.text; // 服务器上的用户名
IdSMTP1.Password := Edit25.text; // 服务器上的密码
IdSMTP1.Host := Combobox21.text; // 服务器SMTP地址
IdSMTP1.Port := StrToInt(Combobox22.text); // 服务器端口
try
IdSMTP1.Connect;
except
statusbar1.Panels[0].text:=IntToStr(List)+'、无法连接到服务器!';
exit;
end;