سورس لارسال اميل به مشكل
#4
مع اني وضعتو في المرفقات
PHP كود :
unit mainunit;

interface

uses
  inifiles
, windows, messages, sysutils, variants, classes, graphics, controls, forms,
  
dialogs, idcomponent, idtcpconnection, idtcpclient, idmessageclient,
  
idsmtp, comctrls, stdctrls, buttons, extctrls, idbasecomponent, idmessage;

type
  tmailerform 
= class(tform)
    
mailmessage: Tidmessage;
    
pnltop: Tpanel;
    
pnlbottom: Tpanel;
    
ledhost: Tlabelededit;
    
body: Tmemo;
    
ledattachment: Tlabelededit;
    
btnattachment: Tbitbtn;
    
smtp: Tidsmtp;
    
ledfrom: Tlabelededit;
    
ledto: Tlabelededit;
    
ledcc: Tlabelededit;
    
ledsubject: Tlabelededit;
    
btnsendmail: Tbitbtn;
    
statusmemo: Tmemo;
    
attachmentdialog: Topendialog;
    
procedure btnsendmailclick(sender: Tobject);
    
procedure smtpstatus(asender: Tobject; const astatus: Tidstatus;
      const 
astatustext: String);
    
procedure btnattachmentclick(sender: Tobject);
    
procedure formcreate(sender: Tobject);
    
procedure formclose(sender: Tobject; var action: Tcloseaction);
  private
    
procedure getsettings;
    
procedure savesettings;
  public
    { public 
declarations }
  
end;

var
  
mailerform: Tmailerform;

implementation

{$r *.dfm}

procedure tmailerform.btnsendmailclick(sender: Tobject);
begin
  statusmemo
.clear;

  
//setup smtp
  
smtp.host := ledhost.text;
  
smtp.port := 25;

  
//setup mail message
  
mailmessage.from.address := ledfrom.text;
  
mailmessage.recipients.emailaddresses := ledto.text + ',' + ledcc.text;

  
mailmessage.subject := ledsubject.text;
  
mailmessage.body.text := body.text;

  if 
fileexists(ledattachment.text) then
    tidattachment
.create(mailmessage.messageparts, ledattachment.text);

  
//send mail
  
try
    try
      
smtp.connect(1000);
      
smtp.send(mailmessage);
    
except on e:exception do
      
statusmemo.lines.insert(0, 'error: ' + e.message);
    
end;
  finally
    if 
smtp.connected then smtp.disconnect;
  
end;

end; (* btnsendmail click *)

procedure tmailerform.smtpstatus(asender: Tobject; const astatus: Tidstatus;
  const 
astatustext: String);
begin
  statusmemo
.lines.insert(0,'status: ' + astatustext);
end; (* smtp status *)

procedure tmailerform.btnattachmentclick(sender: Tobject);
begin
  
if attachmentdialog.execute then
    ledattachment
.text := attachmentdialog.filename;
end;

procedure tmailerform.formcreate(sender: Tobject);
begin
  getsettings
;
end;

procedure tmailerform.formclose(sender: Tobject; var action: Tcloseaction);
begin
  savesettings
;
end;

procedure tmailerform.getsettings;
var
  
ini : Tinifile;
begin
  ini 
:= tinifile.create(changefileext(application.exename,'.ini'));
  try
    
ledhost.text := ini.readstring('smtp','host','');

    
ledfrom.text := ini.readstring('mail','from','');
    
ledto.text := ini.readstring('mail','to','');
    
ledcc.text := ini.readstring('mail','cc','');
  finally
    
ini.free;
  
end;
end; (* getsettings *)

procedure tmailerform.savesettings;
var
  
ini : Tinifile;
begin
  ini 
:= tinifile.create(changefileext(application.exename,'.ini'));
  try
    
ini.writestring('smtp','host',ledhost.text);

    
ini.writestring('mail','from',ledfrom.text);
    
ini.writestring('mail','to',ledto.text);
    
ini.writestring('mail','cc',ledcc.text);
  finally
    
ini.free;
  
end;
end; (* savesettings *)

end 
اللهم اهدنا واهد بنا وجعلنا سببا لم اهتدى
الرد


الردود في هذا الموضوع
سورس لارسال اميل به مشكل - بواسطة Benhlell - 29-06-2010, 10:02 PM
سورس لارسال اميل به مشكل - بواسطة TF6M - 27-09-2010, 12:11 PM
سورس لارسال اميل به مشكل - بواسطة bibill - 29-09-2010, 11:37 AM
سورس لارسال اميل به مشكل - بواسطة andreo - 01-07-2010, 11:39 PM
سورس لارسال اميل به مشكل - بواسطة Benhlell - 03-07-2010, 06:27 PM

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم