Fast Report - E-Mail Client (Batch) & E-Mail (Native): Difference between revisions
From eStream Software
(Created page with "==Introduction== By default we got 2 types of Export to E Mail for Fast Report * E-Mail Client (Batch) * E-Mail (Native) ==E-Mail Client (Batch)== Pros * Can use for Batch &...") |
(→Setup) |
||
Line 21: | Line 21: | ||
==Setup== | ==Setup== | ||
Below is example using Sales Invoice | |||
:01. Click the Code Tab | |||
:02. Enter below Script at the First line | |||
<syntaxhighlight lang="delphi"> | |||
var lSQL : String; | |||
procedure GetEMailTpl; | |||
var D : TfrxDataSet; | |||
begin | |||
D := Report.GetDataSet('plEMailTpl'); | |||
D.First; | |||
While not D.Eof do begin | |||
if Trim(D.DisplayText('ReportName')) = Trim(Report.ReportOptions.Name) then | |||
Break; | |||
D.Next; | |||
end; | |||
end; | |||
//For E-Mail Client (Batch) | |||
procedure OnGetEmailSettings(EmailSettings: TStrings); | |||
var vEmail, vName: Variant; | |||
begin | |||
GetEMailTpl; | |||
vEmail := Trim(<Document_CompanyBranch."Email">); | |||
if Trim(vEmail) = '' then | |||
vEmail := <plEMailTpl."AltEMail">; | |||
vName := Trim(<Main."CompanyName">); | |||
if (vName <> '' ) and (vEmail <> '') then begin | |||
EmailSettings.Values['Recipients'] := vEmail; | |||
EmailSettings.Values['Subject'] := <plEMailTpl."Subject">; | |||
EmailSettings.Values['Body'] := RichTextToPlainText(<plEMailTpl."Body">); | |||
end; | |||
//ID uses for display on progress dialog | |||
EmailSettings.Values['ID'] := vName; | |||
end; | |||
//For E-Mail (Native) | |||
function SQL_Email_GetInfo(Info: Integer): string; | |||
var vEmail, vName: Variant; | |||
begin | |||
GetEMailTpl; | |||
Result := ''; | |||
vEmail := Trim(<Document_CompanyBranch."Email">); | |||
if Trim(vEmail) = '' then | |||
vEmail := <plEMailTpl."AltEMail">; | |||
vName := Trim(<Main."CompanyName">); | |||
if (vName <> '' ) and (vEmail <> '') then begin | |||
case Info of | |||
SQL_Email_Address: Result := vEmail; | |||
SQL_Email_Subject: Result := <plEMailTpl."Subject">; | |||
SQL_Email_Content: Result := RichTextToPlainText(<plEMailTpl."Body">); | |||
end; | |||
end; | |||
end; | |||
</syntaxhighlight> |
Revision as of 04:34, 18 April 2016
Introduction
By default we got 2 types of Export to E Mail for Fast Report
- E-Mail Client (Batch)
- E-Mail (Native)
E-Mail Client (Batch)
Pros
- Can use for Batch & Single Document E-Mail
- Sended E-Mail will had keep in the Client E-Mail
Cons
- Not easy to setup
E-Mail (Native)
Pros
- Easy to Setup
Cons
- No record is keeped for Sended E-Mail
- Only For Single Document E-Mail
Setup
Below is example using Sales Invoice
- 01. Click the Code Tab
- 02. Enter below Script at the First line
var lSQL : String;
procedure GetEMailTpl;
var D : TfrxDataSet;
begin
D := Report.GetDataSet('plEMailTpl');
D.First;
While not D.Eof do begin
if Trim(D.DisplayText('ReportName')) = Trim(Report.ReportOptions.Name) then
Break;
D.Next;
end;
end;
//For E-Mail Client (Batch)
procedure OnGetEmailSettings(EmailSettings: TStrings);
var vEmail, vName: Variant;
begin
GetEMailTpl;
vEmail := Trim(<Document_CompanyBranch."Email">);
if Trim(vEmail) = '' then
vEmail := <plEMailTpl."AltEMail">;
vName := Trim(<Main."CompanyName">);
if (vName <> '' ) and (vEmail <> '') then begin
EmailSettings.Values['Recipients'] := vEmail;
EmailSettings.Values['Subject'] := <plEMailTpl."Subject">;
EmailSettings.Values['Body'] := RichTextToPlainText(<plEMailTpl."Body">);
end;
//ID uses for display on progress dialog
EmailSettings.Values['ID'] := vName;
end;
//For E-Mail (Native)
function SQL_Email_GetInfo(Info: Integer): string;
var vEmail, vName: Variant;
begin
GetEMailTpl;
Result := '';
vEmail := Trim(<Document_CompanyBranch."Email">);
if Trim(vEmail) = '' then
vEmail := <plEMailTpl."AltEMail">;
vName := Trim(<Main."CompanyName">);
if (vName <> '' ) and (vEmail <> '') then begin
case Info of
SQL_Email_Address: Result := vEmail;
SQL_Email_Subject: Result := <plEMailTpl."Subject">;
SQL_Email_Content: Result := RichTextToPlainText(<plEMailTpl."Body">);
end;
end;
end;