J
jiangzhang3942
Unregistered / Unconfirmed
GUEST, unregistred user!
如题,谁能给我一个发邮件(带附件的)程序,以前写的一个用了很久但是不知道最近为什么不行了,以下是源程序:
unit SendEmail;
interface
uses windows, IdBaseComponent, IdMessage, IdComponent,IdTCPConnection, IdTCPClient, IdMessageClient, IdSMTP,Classes;
function MySendEmail : boolean;
procedure init(MyUserEmail,MySmtpServerUser,MySmtpServerPassword,MySmtpServerName,
MyFromText,MySSubject,MySFuJian : string;MySBody : Tstrings);
var
IdMsgSend : TIdMessage;
SMTP : TIdSMTP;
SBody : Tstrings;//内容
UserEmail:string;//收件人邮件地址
SmtpAuthType:integer;//验证
SmtpServerUser:string;//登陆SMTP服务器的用户名
SmtpServerPassword:string;//登陆SMTP服务器用到的密码
SmtpServerName:string;//SMTP服务器名.例如:smtp.sohu.com
SmtpServerPort:integer;//SMTP服务器端口,默认的是25
FromText : string;//发件人地址
SSubject : string;//邮件主体/
SFuJian : string;//附件路径
implementation
function MySendEmail : boolean;
begin
result := false;
with IdMsgSend do
begin
Body.Assign(SBody); //需要赋值?????????
From.Text := FromText; //发件人 需要赋值?????????
ReplyTo.EMailAddresses :=UserEmail ;
Recipients.EMailAddresses :=UserEmail; { To: header }//收件人地址
Subject := SSubject; { Subject: header } //邮件主体
ReceiptRecipient.Text := '';
end;
case SmtpAuthType of
0: SMTP.AuthenticationType := atNone;
1: SMTP.AuthenticationType := atLogin; {Simple Login }
end;
SMTP.Userid := SmtpServerUser;
SMTP.Password := SmtpServerPassword;
TIdAttachment.Create(IdMsgSend.MessageParts, SFuJian);//添加附件 需要赋值?????????
SMTP.Host := SmtpServerName;
SMTP.Port := SmtpServerPort;
SMTP.Connect;
try
SMTP.Send(IdMsgSend);
result := true;
finally
SMTP.Disconnect;
end;
end;
procedure init(MyUserEmail,MySmtpServerUser,MySmtpServerPassword,MySmtpServerName,
MyFromText,MySSubject,MySFuJian : string;MySBody : Tstrings);
begin
UserEmail := MyUserEmail; //收件人邮件地址
SmtpAuthType := 1; //验证
SmtpServerUser := MySmtpServerUser;//登陆SMTP服务器的用户名
SmtpServerPassword := MySmtpServerPassword; //登陆SMTP服务器用到的密码
SmtpServerName := MySmtpServerName; //SMTP服务器名.例如:smtp.sohu.com
SmtpServerPort := 25; //SMTP服务器端口,默认的是25 }
FromText := MyFromText;//发件人
SSubject := MySSubject;//邮件主题
SFuJian := MySFuJian;//附件地址
SBody := MySBody;//邮件内容
end;
initialization
IdMsgSend := TIdMessage.Create(nil);
SMTP := TIdSMTP.Create(nil);
SBody := Tstringlist.Create;
finalization
IdMsgSend.Free;
SMTP.Free;
// SBody.Free;
end.
谁有比较好的一个能给我一份吗?
unit SendEmail;
interface
uses windows, IdBaseComponent, IdMessage, IdComponent,IdTCPConnection, IdTCPClient, IdMessageClient, IdSMTP,Classes;
function MySendEmail : boolean;
procedure init(MyUserEmail,MySmtpServerUser,MySmtpServerPassword,MySmtpServerName,
MyFromText,MySSubject,MySFuJian : string;MySBody : Tstrings);
var
IdMsgSend : TIdMessage;
SMTP : TIdSMTP;
SBody : Tstrings;//内容
UserEmail:string;//收件人邮件地址
SmtpAuthType:integer;//验证
SmtpServerUser:string;//登陆SMTP服务器的用户名
SmtpServerPassword:string;//登陆SMTP服务器用到的密码
SmtpServerName:string;//SMTP服务器名.例如:smtp.sohu.com
SmtpServerPort:integer;//SMTP服务器端口,默认的是25
FromText : string;//发件人地址
SSubject : string;//邮件主体/
SFuJian : string;//附件路径
implementation
function MySendEmail : boolean;
begin
result := false;
with IdMsgSend do
begin
Body.Assign(SBody); //需要赋值?????????
From.Text := FromText; //发件人 需要赋值?????????
ReplyTo.EMailAddresses :=UserEmail ;
Recipients.EMailAddresses :=UserEmail; { To: header }//收件人地址
Subject := SSubject; { Subject: header } //邮件主体
ReceiptRecipient.Text := '';
end;
case SmtpAuthType of
0: SMTP.AuthenticationType := atNone;
1: SMTP.AuthenticationType := atLogin; {Simple Login }
end;
SMTP.Userid := SmtpServerUser;
SMTP.Password := SmtpServerPassword;
TIdAttachment.Create(IdMsgSend.MessageParts, SFuJian);//添加附件 需要赋值?????????
SMTP.Host := SmtpServerName;
SMTP.Port := SmtpServerPort;
SMTP.Connect;
try
SMTP.Send(IdMsgSend);
result := true;
finally
SMTP.Disconnect;
end;
end;
procedure init(MyUserEmail,MySmtpServerUser,MySmtpServerPassword,MySmtpServerName,
MyFromText,MySSubject,MySFuJian : string;MySBody : Tstrings);
begin
UserEmail := MyUserEmail; //收件人邮件地址
SmtpAuthType := 1; //验证
SmtpServerUser := MySmtpServerUser;//登陆SMTP服务器的用户名
SmtpServerPassword := MySmtpServerPassword; //登陆SMTP服务器用到的密码
SmtpServerName := MySmtpServerName; //SMTP服务器名.例如:smtp.sohu.com
SmtpServerPort := 25; //SMTP服务器端口,默认的是25 }
FromText := MyFromText;//发件人
SSubject := MySSubject;//邮件主题
SFuJian := MySFuJian;//附件地址
SBody := MySBody;//邮件内容
end;
initialization
IdMsgSend := TIdMessage.Create(nil);
SMTP := TIdSMTP.Create(nil);
SBody := Tstringlist.Create;
finalization
IdMsgSend.Free;
SMTP.Free;
// SBody.Free;
end.
谁有比较好的一个能给我一份吗?