Delphi6 中的 indy可不可以收QQ邮件,谁可以给个完整的例子。

xiaoxingchi 2008-08-05 12:35:06
如题
...全文
93 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaoxingchi 2008-08-20
  • 打赏
  • 举报
回复
已经搞定了,谢谢各位
xiaoxingchi 2008-08-06
  • 打赏
  • 举报
回复
谢谢2楼的。那是发邮件的,我要的是收邮件的
hongqi162 2008-08-05
  • 打赏
  • 举报
回复
hongqi162 2008-08-05
  • 打赏
  • 举报
回复
你可以看看idpop3,smtp那是发送邮件的
kampan 2008-08-05
  • 打赏
  • 举报
回复
阿日 很少来了.....
QQ邮件与其他的不一样吗,应该是可以的,有个专门的控件好像是IdSMTPServer
翻出一份源码,你参考下:

unit Main;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
IdBaseComponent, IdComponent, IdTCPServer, IdSMTPServer, StdCtrls,
IdMessage, IdEMailAddress;

type
TForm1 = class(TForm)
Memo1: TMemo;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
ToLabel: TLabel;
FromLabel: TLabel;
SubjectLabel: TLabel;
IdSMTPServer1: TIdSMTPServer;
Label4: TLabel;
Button1: TButton;
Button2: TButton;
procedure IdSMTPServer1ADDRESSError(AThread: TIdPeerThread;
const CmdStr: String);
procedure IdSMTPServer1CommandAUTH(AThread: TIdPeerThread;
const CmdStr: String);
procedure IdSMTPServer1CommandCheckUser(AThread: TIdPeerThread;
const Username, Password: String; var Accepted: Boolean);
procedure IdSMTPServer1CommandQUIT(AThread: TIdPeerThread);
procedure IdSMTPServer1CommandX(AThread: TIdPeerThread;
const CmdStr: String);
procedure IdSMTPServer1CommandMAIL(const ASender: TIdCommand;
var Accept: Boolean; EMailAddress: String);
procedure IdSMTPServer1CommandRCPT(const ASender: TIdCommand;
var Accept, ToForward: Boolean; EMailAddress: String;
var CustomError: String);
procedure IdSMTPServer1ReceiveRaw(ASender: TIdCommand;
var VStream: TStream; RCPT: TIdEMailAddressList;
var CustomError: String);
procedure IdSMTPServer1ReceiveMessage(ASender: TIdCommand;
var AMsg: TIdMessage; RCPT: TIdEMailAddressList;
var CustomError: String);
procedure IdSMTPServer1ReceiveMessageParsed(ASender: TIdCommand;
var AMsg: TIdMessage; RCPT: TIdEMailAddressList;
var CustomError: String);
procedure IdSMTPServer1CommandHELP(ASender: TIdCommand);
procedure IdSMTPServer1CommandSAML(ASender: TIdCommand);
procedure IdSMTPServer1CommandSEND(ASender: TIdCommand);
procedure IdSMTPServer1CommandSOML(ASender: TIdCommand);
procedure IdSMTPServer1CommandTURN(ASender: TIdCommand);
procedure IdSMTPServer1CommandVRFY(ASender: TIdCommand);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.IdSMTPServer1ADDRESSError(AThread: TIdPeerThread;
const CmdStr: String);
begin
// Send the Address Error String - this *WILL* be coded in eventually.
AThread.Connection.Writeln('500 Syntax Error in MAIL FROM or RCPT TO');
end;

procedure TForm1.IdSMTPServer1CommandAUTH(AThread: TIdPeerThread;
const CmdStr: String);
begin
// This is where you would process the AUTH command - for now, we send a error
AThread.Connection.Writeln(IdSMTPServer1.Messages.ErrorReply);
end;

procedure TForm1.IdSMTPServer1CommandCheckUser(AThread: TIdPeerThread;
const Username, Password: String; var Accepted: Boolean);
begin
// This event allows you to 'login' a user - this is used internall in the
// IdSMTPServer to validate users connecting using the AUTH.
Accepted := False;
end;

procedure TForm1.IdSMTPServer1CommandQUIT(AThread: TIdPeerThread);
begin
// Process any logoff events here - e.g. clean temp files
end;

procedure TForm1.IdSMTPServer1CommandX(AThread: TIdPeerThread;
const CmdStr: String);
begin
// You can use this for debugging :)

end;

procedure TForm1.IdSMTPServer1CommandMAIL(const ASender: TIdCommand;
var Accept: Boolean; EMailAddress: String);
begin
// This is required!
// You check the EMAILADDRESS here to see if it is to be accepted / processed.
// Set Accept := True if its allowed
Accept := True;
end;

procedure TForm1.IdSMTPServer1CommandRCPT(const ASender: TIdCommand;
var Accept, ToForward: Boolean; EMailAddress: String;
var CustomError: String);
begin
// This is required!
// You check the EMAILADDRESS here to see if it is to be accepted / processed.
// Set Accept := True if its allowed
// Set ToForward := True if its needing to be forwarded.
Accept := True;
end;

procedure TForm1.IdSMTPServer1ReceiveRaw(ASender: TIdCommand;
var VStream: TStream; RCPT: TIdEMailAddressList;
var CustomError: String);
begin
// This is the main event for receiving the message itself if you are using
// the ReceiveRAW method
// The message data will be given to you in VSTREAM
// Capture it using a memorystream, filestream, or whatever type of stream
// is suitable to your storage mechanism.
// The RCPT variable is a list of recipients for the message
end;

procedure TForm1.IdSMTPServer1ReceiveMessage(ASender: TIdCommand;
var AMsg: TIdMessage; RCPT: TIdEMailAddressList;
var CustomError: String);
begin
// This is the main event if you have opted to have idSMTPServer present the message packaged as a TidMessage
// The AMessage contains the completed TIdMessage.
// NOTE: Dont forget to add IdMessage to your USES clause!

ToLabel.Caption := AMsg.Recipients.EMailAddresses;
FromLabel.Caption := AMsg.From.Text;
SubjectLabel.Caption := AMsg.Subject;
Memo1.Lines := AMsg.Body;

// Implement your file system here :)
end;

procedure TForm1.IdSMTPServer1ReceiveMessageParsed(ASender: TIdCommand;
var AMsg: TIdMessage; RCPT: TIdEMailAddressList;
var CustomError: String);
begin
// This is the main event if you have opted to have the idSMTPServer to do your parsing for you.
// The AMessage contains the completed TIdMessage.
// NOTE: Dont forget to add IdMessage to your USES clause!

ToLabel.Caption := AMsg.Recipients.EMailAddresses;
FromLabel.Caption := AMsg.From.Text;
SubjectLabel.Caption := AMsg.Subject;
Memo1.Lines := AMsg.Body;

// Implement your file system here :)

end;

procedure TForm1.IdSMTPServer1CommandHELP(ASender: TIdCommand);
begin
// here you can send back a lsit of supported server commands
end;

procedure TForm1.IdSMTPServer1CommandSAML(ASender: TIdCommand);
begin
// not really used anymore - see RFC for information
end;

procedure TForm1.IdSMTPServer1CommandSEND(ASender: TIdCommand);
begin
// not really used anymore - see RFC for information
end;

procedure TForm1.IdSMTPServer1CommandSOML(ASender: TIdCommand);
begin
// not really used anymore - see RFC for information
end;

procedure TForm1.IdSMTPServer1CommandTURN(ASender: TIdCommand);
begin
// not really used anymore - see RFC for information
end;

procedure TForm1.IdSMTPServer1CommandVRFY(ASender: TIdCommand);
begin
// not really used anymore - see RFC for information
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
IdSMTPServer1.active := true;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
IdSMTPServer1.active := false;
end;

***************************** * GRG-Mail V1.0 * ***************************** /****************************************************/ 一.帐户设置: 在程序第一次运行时,会提示您设置第一个帐户,请按下例设置 如一个帐户为ppp(帐户名最好用英文),电子信箱为pan@163.com 则有 帐户名:ppp 用户名:null 密码:******* POP服务器地址:pop.163.com SMTP服务器地址:smtp.163.com 用户电子信箱:null@163.com 注意:帐户名与用户名无关,仅是为了便于管理,密码就是你的电子邮箱密码 POP服务器地址,SMTP服务器地址具体设置请登陆邮件服务供应商相关网页 二.邮件 选择一个帐户,确认你的Internet连接,点击邮件的相关按钮及菜单,当 登陆成功后,便开始邮件,并在最后显示新邮件的数目。 三.地址管理 您可以进入地址簿对其进行添加,删除,修改,回复操作,也可 选择邮件将其自动加入地址簿。 四.发邮件 1.选择一个帐户,点击写新邮件的相关按钮和菜单,进入发邮件窗口 写主题,及件人地址(也可从地址簿加入),然后加入附件(最好 不要太大!),单击发送。 /****************************************************/ 其他功能: 1.数据库管理 2.支持浏览器/文本模式阅读 3.附件管理 /****************************************************/ 本人在邮件开发过程寻找了很多关于邮件发的例子程序,始终没有找到完整合适的delphi代码,好不容易找到一个,不仅错误很多,而且却连基本的邮件功能都没有实现,最后在参考各位网友的作品的基础上重新编写程序,经过近半个月的努力,总算写出了一个能实现完整邮件发的邮件客户端发程序,由于时间仓促,虽然功能不是很多,但基本的功能可以完整地实现,现在网上发布编译好的程序,请各位批评指正,想要学习邮件发的,兄弟可以提供源代码,请发邮件给我 电子邮件:37711201@qq.com /****************************************************/ 2007.1.1

1,593

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧