要做个能收发电子邮件(用SMTP和POP协议)的模块?各位大侠能否给个源代码示例?
解决方案 »
- 大家有谁用过DelphiCodeToDoc,它到底之不支持中文?谁又可以支持中文的发给我一份好吗?
- Report Machine 如何设置页面大小
- 求一套使用sql库的库存管理系统源代码(delphi)
- 拿分!!!!!!!!!!!LY 请进入,,,,!!!!!!!!
- 请问哪有delphi开发组件的电子书?或是书店有这样的书?
- 在DELPHI7.0中,为什么找不到QReport组件页。
- 有誰知道套打(只打印数据,不打格式),全打的简单方法,告述我,大大的给分
- 关于DELPHI代码格式化的软件
- 09年被辞工,火速求助
- 怎样做到像OUTLOOK EXPRESS那样的效果?
- Tchart中如何动态添加设置饼形图的labels属性呢?
- 怎么知道双击 dbgrid(或 dbgrideh)时是在 Title 上双击的?
我的email:[email protected]
try
NMPOP31.Connect;
except
lpText:= '连接POP3服务器失败。请检查通信设置是否正确,稍后再试。'+CHR(13)+
'[状态:连接]'+CHR(13)+CHR(13)+
'WinSock Error: [10060] Connection timed out.';
MessageBox(Application.Handle, PChar(lpText), PChar(frmDataReceive.Caption), MB_OK+MB_ICONERROR);
end; screen.Cursor := crHourGlass ; mailcelln := 0 ;
if NMPOP31.MailCount > 0 then
begin
//mailcelln控制符合条件的邮件显示到stringgrid1中.
for getM := 1 to NMPOP31.MailCount do
retrieveEnd(false);
stringgrid1.RowCount := mailcelln + 1 ;
// NMPOP31.GetSummary(getM); //mailcelln 变量改为控制将stringgrid1中显示的邮件实现接收到本地.
for mailcelln := 1 to stringgrid1.RowCount-1 do
begin
retrieveEnd(true) ; mailcount := mailcount + NMPOP31.MailMessage.Attachments.Count ; for m := 0 to NMPOP31.MailMessage.Attachments.Count-1 do
begin //对附件进行处理 zbfilestr := NMPOP31.MailMessage.Attachments.Strings[m] ;
....
end; end;
mailcelln := mailcelln-1 ; end
else
ShowMessage('没有可接收的邮件!'); NMPOP31.Disconnect;
screen.Cursor := crDefault ; showmessage('接收了 '+inttostr(mailcelln)+'个新邮件! 恢复了'+inttostr(mailcount)+'个数据文件!') ;
//发送部分自己考虑吧,差不多的
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdMessage, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdMessageClient, IdSMTP, StdCtrls;type
TForm1 = class(TForm)
Label1: TLabel;
edt_SMTP: TEdit;
Label2: TLabel;
edt_From: TEdit;
Label3: TLabel;
edt_To: TEdit;
Lable4: TLabel;
edt_Username: TEdit;
Label4: TLabel;
edt_Psw: TEdit;
Label5: TLabel;
edt_Subject: TEdit;
Label6: TLabel;
Memo1: TMemo;
Label7: TLabel;
edt_File: TEdit;
Button1: TButton;
Button2: TButton;
OpenDialog1: TOpenDialog;
IdSMTP1: TIdSMTP;
IdMessage1: TIdMessage;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
//添加附件
Opendialog1.Filename:='';
Opendialog1.Filter:='所有文件|*.*';
if Opendialog1.Execute then
begin
edt_File.Text:=Opendialog1.FileName;
end;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
//
IdMessage1.From.Address:=edt_From.Text;
//
IdMessage1.From.Name:=edt_Username.Text;
//
Idmessage1.Recipients.EMailAddresses:=edt_To.Text;
//
Idmessage1.Subject:=edt_Subject.Text;
//
Idmessage1.Body.Add(Memo1.Text);
//
TidAttachment.Create(Idmessage1.MessageParts,edt_File.Text);
//
Idsmtp1.Host:=edt_SMTP.Text;
//
Idsmtp1.Username:=edt_Username.Text;
//
Idsmtp1.Password:=edt_Psw.Text;
//
Idsmtp1.AuthenticationType:=atLogin;
//
Idsmtp1.Connect();
//
Idsmtp1.Send(Idmessage1);
end;end.
在线求救!!!!先谢了!