TTMSFNCCloudGoogleGmail
Usage
A component that provides access to the Google GMail service. It allows to retrieve and send email messages in HTML or plain text format. File attachments can be included when sending emails.
Authorization information
Client ID, Client Secret, CallBack URL
Properties
| Property name | Description |
|---|---|
| Files | A list of files to be included as attachment |
| Labels | A list of available labels |
| Mails | A list of emails |
Methods
| Method name | Description |
|---|---|
| DeleteMessage | Permanently deletes the specified email |
| GetLabels | Retrieves all available labels and fills the list of Labels |
| GetMails | Retrieves all emails with the specified Label. Mails can be filtered with the AQuery parameter. View a list of search operators |
| RemoveMessagelabels | Removes the labels for a specific email (Accepts a list of label id's separated by a comma) |
| SendMessage, SendMailMessage | Sends an email |
| UpdateMessageLabels | Add labels for a specific email (Accepts a list of label id's separated by a comma) |
Samples
- Sending an email message
var
msgGMail: TTMSFNCCloudGoogleGmailMessage;
begin
msgGMail := TTMSFNCCloudGoogleGmailMessage.Create;
msgGMail.ToRecipients.Add('name@domain.com');
msgGMail.Subject := 'email subject';
msgGMail.Body := '<b>Hello World!</b><br>This is an email message';
msgGMail.MessageType := mtHTML;
TMSFNCCloudGoogleGmail1.SendMailMessage(msgGMail);
end;
- Include an inline image as attachment in an email message
Note
Make sure to add a unique value to the ContentID property of the TTMSFNCCloudGoogleGMailFile object. Then use the value as a reference in the email message Body.
var
fileGMail: TTMSFNCCloudGoogleGmailFile;
begin
if OpenDialog1.Execute then
begin
fileGMail := TMSFNCCloudGoogleGmail1.Files.Add;
fileGMail.&File := OpenDialog1.FileName;
fileGMail.ContentID := 'InlineImage' + IntToStr(TMSFNCCloudGoogleGmail1.Files.Count);
fileGMail.IsInline := True;
msgGMail.Body := msgGMail.Body + #10#13 + '<img src="cid:' + fileGMail.ContentID + '">';
end;
end;
- Receiving mails with inline images
A helper function GetBodyWithInlineImages is available that will automatically download and convert attached inline images in the Body text of theMail
begin
WebBrowser1.LoadFromStrings(TMSFNCCloudGoogleGmail1.Mails[lbMails.ItemIndex].GetBodyWithInlineImages, '');
end;
Note
A complete example is provided in the Demos folder as GMailOutlookMail Demo