Skip to content

Commit

Permalink
Merge pull request exilon#45 from turric4n/master_turrican
Browse files Browse the repository at this point in the history
Master turrican >> [SMTP] >> Added ReplyTo property to TMailMessage.
  • Loading branch information
exilon authored Jul 29, 2020
2 parents d7560ca + 0f8fcdf commit fc3f4ee
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions Quick.SMTP.pas
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{ ***************************************************************************
Copyright (c) 2016-2020 Kike Pérez
Copyright (c) 2016-2020 Kike P�rez
Unit : Quick.SMTP
Description : Send Emails
Author : Kike Pérez
Author : Kike P�rez
Version : 1.4
Created : 12/10/2017
Modified : 07/07/2020
Modified : 29/07/2020
This file is part of QuickLib: https://github.com/exilon/QuickLib
Expand Down Expand Up @@ -58,6 +58,7 @@ TMailMessage = class
fBody : string;
fCC : string;
fBCC : string;
fReplyTo : string;
fBodyFromFile : Boolean;
fAttachments : TStringList;
procedure SetBody(aValue : string);
Expand All @@ -71,6 +72,7 @@ TMailMessage = class
property Body : string read fBody write SetBody;
property CC : string read fCC write fCC;
property BCC : string read fBCC write fBCC;
property ReplyTo : string read fReplyTo write fReplyTo;
property Attachments : TStringList read fAttachments write fAttachments;
procedure AddBodyFromFile(const cFileName : string);
end;
Expand All @@ -89,8 +91,8 @@ TSMTP = class(TIdSMTP)
property Mail : TMailMessage read fMail write fMail;
function SendMail: Boolean; overload;
function SendMail(aMail : TMailMessage) : Boolean; overload;
function SendEmail(const aFromEmail,aFromName,aSubject,aTo,aCC,aBC,aBody : string) : Boolean; overload;
function SendEmail(const aFromName,aSubject,aTo,aCC,aBC,aBody : string) : Boolean; overload;
function SendEmail(const aFromEmail,aFromName,aSubject,aTo,aCC,aBC,aReplyTo,aBody : string) : Boolean; overload;
function SendEmail(const aFromName,aSubject,aTo,aCC,aBC,aReplyTo,aBody : string) : Boolean; overload;
end;

implementation
Expand Down Expand Up @@ -149,13 +151,13 @@ destructor TSMTP.Destroy;
inherited;
end;

function TSMTP.SendEmail(const aFromEmail, aFromName, aSubject, aTo, aCC, aBC, aBody: string): Boolean;
function TSMTP.SendEmail(const aFromEmail, aFromName, aSubject, aTo, aCC, aBC, aReplyTo, aBody: string): Boolean;
begin
fMail.From := aFromEmail;
Result := SendEmail(aFromName,aSubject,aTo,aCC,aBC,aBody);
Result := SendEmail(aFromName,aSubject,aTo,aCC,aBC,aReplyTo,aBody);
end;

function TSMTP.SendEmail(const aFromName,aSubject,aTo,aCC,aBC,aBody : string) : Boolean;
function TSMTP.SendEmail(const aFromName,aSubject,aTo,aCC,aBC,aReplyTo,aBody : string) : Boolean;
var
mail : TMailMessage;
begin
Expand All @@ -170,6 +172,7 @@ function TSMTP.SendEmail(const aFromName,aSubject,aTo,aCC,aBC,aBody : string) :
Mail.Recipient := aTo;
Mail.CC := aCC;
Mail.BCC := aBC;
Mail.ReplyTo := aReplyTo;
Result := Self.SendMail(mail);
finally
mail.Free;
Expand Down Expand Up @@ -204,6 +207,7 @@ function TSMTP.SendMail(aMail : TMailMessage) : Boolean;
for email in aMail.Recipient.Split([',',';']) do msg.Recipients.Add.Address := email;
for email in aMail.CC.Split([',',';']) do msg.CCList.Add.Address := email;
for email in aMail.BCC.Split([',',';']) do msg.BCCList.Add.Address := email;
for email in aMail.ReplyTo.Split([',',';']) do msg.ReplyTo.Add.Address := email;
if aMail.fBodyFromFile then
begin
msg.Body.LoadFromFile(aMail.Body);
Expand Down

0 comments on commit fc3f4ee

Please sign in to comment.