200分求发邮件代码,用INDY组件(200分)

  • 主题发起人 主题发起人 borlander
  • 开始时间 开始时间
DELPHI 6当中就有用 INDY 写的邮件程序的 DEMO 啊!
 
在DELPHI安装目录下
Program Files/Borland/Delphi6/Demos/Indy/MailClient
有完整的例子。
 
就是那个DEMO有错误
 
以下代码作参考:
procedure TFMmail.Button1Click(Sender: TObject);
begin
NMSMTP1.PostMessage.FromName:='姓名';//在邮件中显示的发件人姓名
NMSMTP1.UserID:='邮件帐号';//如信箱地址为none@163.net,则填入none
NMSMTP1.PostMessage.FromAddress:='发件地址';
NMSMTP1.PostMessage.ReplyTo:='回复地址';
NMSMTP1.Host:='pop3服务器地址';//如163填入:pop.163.net
NMSMTP1.PostMessage.ToAddress.Text:='对方邮箱地址';
NMSMTP1.PostMessage.Subject:='主题';
NMSMTP1.PostMessage.Attachments.AddStrings(Listbox1.Items);//附件文件列表
NMSMTP1.PostMessage.LocalProgram:='xxx';//发邮件的应用程序名
NMSMTP1.PostMessage.Body.Assign(memo1.Lines);//信件内容
if not NMSMTP1.Connected then
NMSMTP1.Connect;
if NMSMTP1.Connected then
begin
NMSMTP1.SendMail;
NMSMTP1.Disconnect;
end;
end;

容错自已去写。
 
procedure TForm1.Button1Click(Sender: TObject);
begin
self.IdSMTP1.Host :='smtp.sohu.com';
self.IdSMTP1.Port :=25;
self.IdSMTP1.Username :='usess';
self.IdSMTP1.Password :='647';
self.idSMTP1.AuthenticationType := atLogin;
idmsgSend.From.Text :='usess@sohu.com';
idMsgSend.Body.text :=memo1.Text;
idMsgSend.Recipients.EMailAddresses :=edit1.Text;
idMsgSend.Subject :=edit2.text;
idmsgSend.ContentType :='TEXT/PLAIN';
self.IdSMTP1.Connect();
try
idSMTP1.Send(IdMsgSend);
finally
idSMTP1.Disconnect;
end;
showmessage('发送成功');
end;
 
如果想实现简单的功能,delphi有自带例子,不知是否要实现其它的功能。
 
看《DELPHI7项目开发实践》,使用TIDMESSAGE+TIDSMTP,有完整代码
 
哦,是这样
 
楼上的,那本书那里又啊?
 
我有,要嘛?!
zhyz@qdatm.net.cn
 
有没有用IMAP4发送邮件的例子
 
http://www.e-bookshop.com.cn/asp/detail.asp?bookID=711305156301
 
我有一个群发邮件的源码,要不?
 
procedure TfrmMessageEditor.bbtnOkClick(Sender: TObject);
begin
with IdMsgSend do //选tidmessage控件和tidsmtp控件
begin
Body.Assign(Memo1.Lines);
From.Text := UserEmail;
ReplyTo.EMailAddresses := UserEmail;
Recipients.EMailAddresses := edtTo.Text; { To: header }
Subject := edtSubject.Text; { Subject: header }
Priority := TIdMessagePriority(cboPriority.ItemIndex); { Message Priority }
CCList.EMailAddresses := edtCC.Text; {CC}
BccList.EMailAddresses := edtBCC.Text; {BBC}
if chkReturnReciept.Checked then
begin {We set the recipient to the From E-Mail address }
ReceiptRecipient.Text := From.Text;
end
else
begin {indicate that there is no receipt recipiant}
ReceiptRecipient.Text := '';
end;
end;

{authentication settings}
case SmtpAuthType of
0: SMTP.AuthenticationType := atNone;
1: SMTP.AuthenticationType := atLogin; {Simple Login}
end;
SMTP.Username := SmtpServerUser;
SMTP.Password := SmtpServerPassword;

{General setup}
SMTP.Host := SmtpServerName;
SMTP.Port := SmtpServerPort;

{now we send the message}
SMTP.Connect;
try
SMTP.Send(IdMsgSend);
finally
SMTP.Disconnect;
end;
end;
 
?????楼上的,那本书那里又啊?
在计算机网络通讯实例中
 
后退
顶部