by Andrew Jam » Wed, 14 Jun 2006 03:25:28
ere's some old code that I wrote a few years ago ...
unit ajMAPI;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Mapi;
type
TajMapiErrorEvent = procedure(Sender : TObject; ErrCode : integer) of
object;
TajMapiControl = class(TComponent)
public
constructor Create (AOwner : TComponent); override;
destructor Destroy; override;
private
fSubject : string;
fMailText : string;
fFromName : string;
fFromAddress : string;
fTOAddress : TStrings;
fCCAddress : TStrings;
fBCCAddress : TStrings;
fAttachedFileName : TStrings;
fDisplayFileName : TStrings;
fShowDialog : boolean;
fOnUserAbort : TNotifyEvent;
fOnMapiError : TajMapiErrorEvent;
fOnSuccess : TNotifyEvent;
procedure SetToAddress (Value : TStrings);
procedure SetCCAddress (Value : TStrings);
procedure SetBCCAddress (Value : TStrings);
procedure SetAttachedFileName (Value : TStrings);
protected
public
procedure SendMail;
procedure Reset;
published
property Subject : string read fSubject
write fSubject;
property Body : string read fMailText
write fMailText;
property FromName : string read fFromName
write fFromName;
property FromAddress : string read fFromAddress
write fFromAddress;
property Recipients : TStrings read fTOAddress
write SetTOAddress;
property CopyTo : TStrings read fCCAddress
write SetCCAddress;
property BlindCopyTo : TStrings read fBCCAddress
write SetBCCAddress;
property AttachedFiles : TStrings read fAttachedFileName
write SetAttachedFileName;
property DisplayFileName : TStrings read fDisplayFileName;
property ShowDialog : boolean read fShowDialog
write fShowDialog;
property OnUserAbort : TNotifyEvent read fOnUserAbort
write fOnUserAbort;
property OnMapiError : TajMapiErrorEvent read fOnMapiError
write fOnMapiError;
property OnSuccess : TNotifyEvent read fOnSuccess
write fOnSuccess;
end;
procedure Register;
implementation
{--------------------------------------------------------------------------------------------------}
constructor TajMapiControl.Create(AOwner : TComponent);
begin
inherited;
fOnUserAbort := nil;
fOnMapiError := nil;
fOnSuccess := nil;
fSubject := '';
fMailtext := '';
fFromName := '';
fFromAddress := '';
fTOAddress := TStringList.Create;
fCCAddress := TStringList.Create;
fBCCAddress := TStringList.Create;
fAttachedFileName := TStringList.Create;
fDisplayFileName := TStringList.Create;
fShowDialog := false;
end; {constructor}
{--------------------------------------------------------------------------------------------------}
destructor TajMapiControl.Destroy;
begin
fTOAddress.Free;
FCCAddress.Free;
FBCCAddress.Free;
fAttachedFileName.Free;
fDisplayFileName.Free;
inherited;
end; {destructor}
{--------------------------------------------------------------------------------------------------}
procedure TajMapiControl.SetToAddre