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.SMTPStatus(ASender: TObject; const AStatus: TIdStatus;
const AStatusText: String);
begin
memo1.Lines.Add('Status:'+AStatusText);
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
opfile.Execute;
if opfile.FileName<>'' then
FileAddress.Text:=opfile.FileName;
end;
D7+indy10发送邮件+附件成功
我最近也在研究这个,想写个网盘程序用,网上找的例子关于网盘的很少