function SendMailViaSendGrid(aAPIKey, mFrom, mTo, mSubj, mText, mAtt: string; var aErr: string): boolean;


This function sends an email to a destination email address using the SendGrid cloud service. Optionally you can attach one file to the message you're sending.
 
Parameters

aAPIKey

The API key you generated for the SendGrid service

mTo

The email address of the recipient

mSubj

The subject of your email message

mText

The contents (text) of your email message

mAtt

The full path to a file you want to attach. This is optional, in order not to attach any file, just pass an empty string.

aErr

A variable that will receive an error message (in case the function fails and returns 'false'

 
Return value

True

The message was sent successfully

False

Error while sending message; the message was not sent, the the value of the aErr variable for further information

 
Remarks
This function could take a very long time to execute depending on the size of the file(s) you are trying to send via email. Please take that into account before using this function in your script. A wise habit is to always check the original file size before attaching it to an email message. This can be done using the FileSize function.

Example


// The following example sends an email to a recipient using SendGrid
var
  lErr: string;
begin
  SendMailViaSendGrid('8i34frw378f7843w', 'myemail@me.com', 'recipien@you.com', 'Some subject', 'Email contents', 'C:\Dox\Attach.pdf', lErr);
end.