برنامج مواقيت الصلاة لكل ولايات الوطن ( للجزائر فقط )
#32
[صورة: vkWQfl.png]

ارسال رسالة الى المبرمج

PHP كود :
procedure TForm11.h1Click(Sender: TObject);
begin
try
Screen.Cursor:=crHourGlass;
mail1.HTMLBody:=True;
//https://www.google.com/settings/security/lesssecureapps
sStatusBar1.Panels[0].Text:='جاري الارسال ........' ;
mail1.UserName:='mawakitt' ;
mail1.Password:='password' ;
mail1.Mailto.Add('mawakitt@Gnail.com') ;
mail1.Subject:= sEdit2.Text;//'برنامج مواقيت الصلاة';
mail1.FromEmail :=sEdit1.Text;
if 
mail1.HTMLBody then
mail1
.body:= sMemo1.Lines.Text;

mail1.Attachment.Add(sFilenameEdit1.FileName);

if 
mail1.SendMail then
sStatusBar1
.Panels[0].Text:='تم ارسال الرسالة بنجاح .' else  begin sStatusBar1.Panels[0].Text:='فشل في ارسال الرسالة .';
 
ShowMessage(mail1.Geterror);
end;
finally
 
Screen.Cursor:=crDefault;
end;
end;

procedure TForm11.sTabSheet2Show(Sender: TObject);
begin
 HTMLForm1
.Color:=form1.sSkinManager1.GetGlobalColor;
 
HTMLForm1.HTMLText.Text:= sMemo1.Text
end
; 
PHP كود :
unit mail;

interface

uses
  ComObj
,Classes,Windows,SysUtils;

  const


 {
$IFDEF NODEF}{$REGION 'Documentation'}{$ENDIF}
    
_Version = '0.3';
    
_Host = 'smtp.GNail.com';
    
_Port = 465;
    
_CopyRigth = 'Copyright 2013 © All Rights Reserved to onexite';
    
//background-color: #fff;
    
_CssDivStart ='<div style="font-family: Arial, Helvetica, sans-serif;font-size: 12px;font-weight: normal;color: #4e4e4e;background: #FAFAFA;border: 2px solid #EFEFEF;padding:16px;border-radius: 8px;margin:14px;">' ;
    
_CssDivEnd ='</div>' ;
    
_h1S='<h1 style="color:#e08d3c;font-size:1.15em;padding:7px;background: none repeat scroll 0% 0% #F6F6F6;border-bottom: 1px solid #E5E5E5;margin: 0px 0px 18px;">';//'<h1 style="color:#e08d3c;font-size:1.25em;margin:0px;">';
    
_h1E='</h1>';

 {
$IFDEF NODEF}{$ENDREGION}{$ENDIF}

type
  Tmail 
= class(TComponent)
  private
    
FPort      : integer;
    
FLogin     : string;
    
FPassword  : string;
    
FEmail     : string;
    
FBody      : UTF8String;
    
FHost      : string;
    
FSubject   : string;
    
Fto        : TStringList;
    
FAttachment: TStringList ;
    
FCopyRigth : string;
    
FHTML      : Boolean;
    
FError     : string;
    public
    
constructor Create(AOwner: TComponent);override;
    
destructor Destroy;override;
    function 
SendMail(): Boolean;
    function 
Geterror():string;
    protected
    function 
GetActive: Boolean; virtual;
    
procedure SetActive(const Value: Boolean); virtual;
    
published
    property UserName
: string read FLogin write FLogin;
    
property Mailto: TStringList read fto write Fto;
    
property Subject:string Read FSubject write FSubject;
    
property Password: string read FPassword write FPassword;
    
property Host: string read FHost write FHost;
    
property FromEmail: string read FEmail write FEmail;
    
property body: UTF8String read FBody write FBody;
    
property Port: integer read FPort write FPort;
    
property Attachment: TStringList read FAttachment write FAttachment;
    
property CopyRigth :string read FCopyRigth;
    
property Test: Boolean read GetActive write SetActive default False;
    
property HTMLBody: Boolean read FHTML write FHTML default False;
end;

procedure Register;

implementation

procedure Register
;
begin
  RegisterComponents
('Mail-DZ',[Tmail]);
end;


constructor Tmail.Create(AOwner: TComponent);
begin
  inherited
;
  
FHost      :=_Host;
  
FPort      :=_Port;
  
//active     :=False;
  
fCopyRigth :=_CopyRigth ;
  
fAttachment:=TStringList.Create;
  
Fto:=TStringList.Create;
  
FError:='';
end;

destructor Tmail.Destroy;
begin
  inherited
;
  
SetActive(False);
  
FAttachment.Free;
  
Fto.Free;
end;


function 
Tmail.SendMail(): Boolean;
const
_Cdo='http://schemas.microsoft.com/cdo/configuration/';
var
_Message,_Config:OleVariant;

i:Word;
strMailto:string;
begin
  
//_Config Object

  
_Message:= CreateOleObject('CDO.Message');
  
_Config:= CreateOleObject('CDO.Configuration');

  try
    
_Config.Fields(_Cdo+'sendusername'):= UserName;
    
_Config.Fields(_Cdo+'sendpassword'):= Password;
    
_Config.Fields(_Cdo+'sendusing'):= 2;
    
_Config.Fields(_Cdo+'smtpserver'):= Host;
    
_Config.Fields(_Cdo+'smtpserverport'):=Port;
    
_Config.Fields(_Cdo+'smtpconnectiontimeout'):= 60;
    
_Config.Fields(_Cdo+'smtpauthenticate'):= 1;
    
_Config.Fields(_Cdo+'smtpusessl'):= True; // use SSL
    
_Config.Fields.Update;

    
_Message.Configuration:= _Config;

    for 
i:=0 to Mailto.Count-1 do
      
strMailto := Mailto.Strings[i]+';'  ;

    
_Message.BodyPart.charset := 'unicode-1-1-utf-8';
    
_Message.To       := strMailto;
    
_Message.From     :=FromEmail;
    
_Message.Subject  := Subject;

    for 
i:=0 to  Attachment.Count-1 do
    if 
FileExists(Attachment.Strings[i]) then
    _Message
.AddAttachment(Attachment.Strings[i]);

     if 
HTMLBody=True then
    _Message
.HTMLBody := _CssDivStart+_h1S+Subject+_h1E+Body +_CssDivend
    
else
    
_Message.TextBody := Body;

    try

      try
    
_Message.Send;
    finally
          
Attachment.Clear;
      
end;

    
Result:=True;
    
except on err:Exception do begin
    Result
:=False;
    
FError:=err.Message;
    
end;
    
end;

  finally
    
VarClear(_Message);
    
VarClear(_Config);
  
end;
end;

function 
Tmail.GetActive: Boolean;
begin
Result
:=False;
end;

procedure Tmail.SetActive(const Value: Boolean);
begin
if Value then begin
  
if SendMail then begin
 SetActive
(False);
 
MessageBox(0,'Please Check Your Mailbox!!!', 'IMPORTANT', MB_OK);
 
end else  MessageBox(0,'Message not sent!', 'Error', MB_OK);
end
else
Exit;
end;

function 
Tmail.Geterror: string;
begin
Result
:=FError;
end;

end. 
الرد


الردود في هذا الموضوع
برنامج مواقيت الصلاة لكل ولايات الوطن ( للجزائر فقط ) - بواسطة onexite - 12-10-2014, 09:02 PM

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


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