Skip to content

Instantly share code, notes, and snippets.

@martinusso
Created January 25, 2017 19:00
Show Gist options
  • Save martinusso/6fe7c9ef6fa10a45e4dce4a442285f54 to your computer and use it in GitHub Desktop.
Save martinusso/6fe7c9ef6fa10a45e4dce4a442285f54 to your computer and use it in GitHub Desktop.
Using: If you call the TAmazonEmailService.Create constructor without arguments the library will look for the following environment variables: AWS_REGION, AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
program Playground;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
Data.Cloud.CloudAPI,
classes,
AmazonEmailAuthentication in 'vendor\delphi-aws-ses\AmazonEmailAuthentication.pas',
AmazonEmailMessage in 'vendor\delphi-aws-ses\AmazonEmailMessage.pas',
AmazonEmailService in 'vendor\delphi-aws-ses\AmazonEmailService.pas',
AmazonEmailServiceConfiguration in 'vendor\delphi-aws-ses\AmazonEmailServiceConfiguration.pas',
AmazonEmailServiceRegions in 'vendor\delphi-aws-ses\AmazonEmailServiceRegions.pas',
AmazonEmailServiceRequests in 'vendor\delphi-aws-ses\AmazonEmailServiceRequests.pas',
BuildQueryParameters in 'vendor\delphi-aws-ses\BuildQueryParameters.pas',
EncodeQueryParams in 'vendor\delphi-aws-ses\EncodeQueryParams.pas',
PopulateResponseInfo in 'vendor\delphi-aws-ses\PopulateResponseInfo.pas',
PrepareRequestSignature in 'vendor\delphi-aws-ses\PrepareRequestSignature.pas';
var
EmailMessage: TEmailMessage;
Response: TCloudResponseInfo;
begin
ReportMemoryLeaksOnShutdown := True;
EmailMessage.Recipients := TArray<string>.Create('[email protected]', '[email protected]');
EmailMessage.FromName := 'Someone';
EmailMessage.FromAddress := '[email protected]';
EmailMessage.Subject := 'This is the subject line with HTML.';
// Text Format
EmailMessage.BodyType := btText;
EmailMessage.Body := 'Hello. I hope you are having a good day.';
{
// HTML format
EmailMessage.BodyType := btHTML;
EmailMessage.Body := '<!DOCTYPE html>' +
'<html>' +
'<body>' +
'<p>' +
'This is an email link:' +
'<a href="mailto:[email protected]?Subject=Hello%20again" target="_top">Send Mail</a>' +
'</p>' +
'<p>' +
'<b>Note:</b> Spaces between words should be replaced by %20 to ensure that the browser will display the text properly.' +
'</p>' +
'</body>' +
'</html>';
}
try
try
TAmazonEmailService.SendMail(EmailMessage, Response);
finally
Writeln('Code: ' + IntToStr(Response.StatusCode));
Writeln('Message: ' + Response.StatusMessage);
end;
Response.Free;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
Readln;
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment