TTMSFNCCloudMicrosoftOutlookMail
Usage
A component that provides access to the Outlook Mail service. It allows to retrieve and send email messages. File attachments can also be included when sending emails.
Authorization information
Client ID, Client Secret, CallBack URL
Organisation
Properties
| Property name | Description |
|---|---|
| Folders | A list of Outlook Folders |
| Mails | A list of Outlook Mail messages |
Methods
| Method name | Description |
|---|---|
| GetFolders | Fill the list of Folders |
| GetMails | Fill the list of Mails. Optionally a FolderID can be specified to only retrieve items from a specificfolder. By default only the items from the ‘Inbox’ folder are retrieved. If no FolderID is specified the items for all folders are returned. For specific system folders the name of the folder can be used as FolderID, this includes ‘Inbox’, ‘Drafts’, ‘SentItems’ and ‘DeletedItems’.Optionally a PageSize and PageIndex can be provided, if not, the first 100 items are returned |
| SendMessage, SendMailMessage | Send an email message. At least one Recipient email address is required, the other parameters are optional |
Samples
- Sending an email message
var
msgOutlook: TTMSFNCCloudMicrosoftOutlookMailItem;
begin
msgOutlook := TTMSFNCCloudMicrosoftOutlookMailItem.Create;
msgOutlook.RecipientEmails.Clear;
msgOutlook.RecipientEmails.Add('name@domain.com');
msgOutlook.Subject := 'email subject';
msgOutlook.Body := '<b>Hello World!</b><br>This is an email message';
msgOutlook.MailType := mtHTML;
TMSFNCCloudMicrosoftOutlookMail1.SendMailMessage(msgOutlook);
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 TTMSFNCCloudMicrosoftOutlookMailFile object. Then use the value as a reference in the email message Body.
var
fileOutlook: TTMSFNCCloudMicrosoftOutlookMailFile;
begin
if OpenDialog1.Execute then
begin
fileOutlook := msgOutlook.Files.Add;
fileOutlook.&File := OpenDialog1.FileName;
fileOutlook.ContentID := 'InlineImage' + IntToStr(msgOutlook.Files.Count);
fileOutlook.IsInline := True;
msgOutlook.Body := msgOutlook.Body + #10#13 + '<img src="cid:' + fileOutlook.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(TMSFNCCloudMicrosoftOutlookMail1.Mails[Index].GetBodyWithInlineImages, '');
end;
Note
A complete example is provided in the Demos folder as GMailOutlookMail Demo