F
freedelphi5
Unregistered / Unconfirmed
GUEST, unregistred user!
mm给我留了一个email。
前日回答问题时贴了一段代码,是个邮件发送程序,出了一些问题。邮件能发出去,对方却收不到,代码如下,大家看看,是不是21cn的有什么过滤
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdMessage, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdMessageClient, IdSMTP, StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Button1: TButton;
IdSMTP1: TIdSMTP;
IdMessage1: TIdMessage;
Memo1: TMemo;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Edit9: TEdit;
Label9: TLabel;
ListView1: TListView;
Button2: TButton;
OpenDialog1: TOpenDialog;
function FindAttachment(stFilename: string): integer;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
procedure ResetAttachmentListView;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
SmtpAuthType: Integer;
UserEmail: string;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
useremail:=edit9.text;
idmessage1.Body.Assign(Memo1.Lines);
idmessage1.From.Text := UserEmail;
idmessage1.Recipients.EMailAddresses := edit1.Text; { To: header }
idmessage1.Subject := edit2.Text; { Subject: header }
idmessage1.CCList.EMailAddresses := edit3.Text; {CC}
idmessage1.BccList.EMailAddresses := edit4.Text; {BBC}
idsmtp1.Host:=edit5.Text;
idsmtp1.UserId:=edit6.Text;
idsmtp1.Password:=edit7.Text;
idsmtp1.Port:=strtoint(edit8.Text);
idsmtp1.Connect;
{now we send the message}
idsmtp1.Send(idmessage1);
// idsmtp1.Disconnect;
end;
function TForm1.FindAttachment(stFilename: string): integer;
var
intIndex: Integer;
found: boolean;
begin
intIndex := -1;
result := -1;
if (idmessage1.MessageParts.Count < 1) then
exit; //no attachments (or anything else)
found := false;
stFilename := uppercase(stFilename);
repeat
inc(intIndex);
if (idmessage1.MessageParts.Items[intIndex] is TIdAttachment) then
begin //general attachment
if stFilename =
uppercase(TIdAttachment(idmessage1.MessageParts.Items[intIndex]).Filename) then
found := true;
end;
until found or (intIndex > Pred(idmessage1.MessageParts.Count));
if found then
result := intIndex
else
result := -1;
end; (* *)
procedure TForm1.ResetAttachmentListView;
var
li: TListItem;
idx: Integer;
begin
listview1.Items.Clear;
for idx := 0 to Pred(Idmessage1.MessageParts.Count) do
begin
li := listview1.Items.Add;
if IdMessage1.MessageParts.Items[idx] is TIdAttachment then
begin
li.ImageIndex := 0;
li.Caption := TIdAttachment(IdMessage1.MessageParts.Items[idx]).Filename;
li.SubItems.Add(TIdAttachment(Idmessage1.MessageParts.Items[idx]).ContentType);
end
else
begin
li.ImageIndex := 1;
li.Caption := Idmessage1.MessageParts.Items[idx].ContentType;
end;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
TIdAttachment.Create(Idmessage1.MessageParts, OpenDialog1.FileName);
ResetAttachmentListView;
end;
end;
end.
前日回答问题时贴了一段代码,是个邮件发送程序,出了一些问题。邮件能发出去,对方却收不到,代码如下,大家看看,是不是21cn的有什么过滤
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdMessage, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdMessageClient, IdSMTP, StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Button1: TButton;
IdSMTP1: TIdSMTP;
IdMessage1: TIdMessage;
Memo1: TMemo;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Edit9: TEdit;
Label9: TLabel;
ListView1: TListView;
Button2: TButton;
OpenDialog1: TOpenDialog;
function FindAttachment(stFilename: string): integer;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
procedure ResetAttachmentListView;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
SmtpAuthType: Integer;
UserEmail: string;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
useremail:=edit9.text;
idmessage1.Body.Assign(Memo1.Lines);
idmessage1.From.Text := UserEmail;
idmessage1.Recipients.EMailAddresses := edit1.Text; { To: header }
idmessage1.Subject := edit2.Text; { Subject: header }
idmessage1.CCList.EMailAddresses := edit3.Text; {CC}
idmessage1.BccList.EMailAddresses := edit4.Text; {BBC}
idsmtp1.Host:=edit5.Text;
idsmtp1.UserId:=edit6.Text;
idsmtp1.Password:=edit7.Text;
idsmtp1.Port:=strtoint(edit8.Text);
idsmtp1.Connect;
{now we send the message}
idsmtp1.Send(idmessage1);
// idsmtp1.Disconnect;
end;
function TForm1.FindAttachment(stFilename: string): integer;
var
intIndex: Integer;
found: boolean;
begin
intIndex := -1;
result := -1;
if (idmessage1.MessageParts.Count < 1) then
exit; //no attachments (or anything else)
found := false;
stFilename := uppercase(stFilename);
repeat
inc(intIndex);
if (idmessage1.MessageParts.Items[intIndex] is TIdAttachment) then
begin //general attachment
if stFilename =
uppercase(TIdAttachment(idmessage1.MessageParts.Items[intIndex]).Filename) then
found := true;
end;
until found or (intIndex > Pred(idmessage1.MessageParts.Count));
if found then
result := intIndex
else
result := -1;
end; (* *)
procedure TForm1.ResetAttachmentListView;
var
li: TListItem;
idx: Integer;
begin
listview1.Items.Clear;
for idx := 0 to Pred(Idmessage1.MessageParts.Count) do
begin
li := listview1.Items.Add;
if IdMessage1.MessageParts.Items[idx] is TIdAttachment then
begin
li.ImageIndex := 0;
li.Caption := TIdAttachment(IdMessage1.MessageParts.Items[idx]).Filename;
li.SubItems.Add(TIdAttachment(Idmessage1.MessageParts.Items[idx]).ContentType);
end
else
begin
li.ImageIndex := 1;
li.Caption := Idmessage1.MessageParts.Items[idx].ContentType;
end;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
TIdAttachment.Create(Idmessage1.MessageParts, OpenDialog1.FileName);
ResetAttachmentListView;
end;
end;
end.