Send HTML Message
This application demonstrates how:
- How to logon to an EWS Session using a profile.
- How to force the profile selection dialog.
- How to create and send a HTML email.
- How to save a message
- How to use inline images in the HTML body.
- How to set a replyto recipient
- How to use the addressbook dialog to select recipients
- How to verify recipients
Example code:
procedure TFrmMain.SetMesageProps(ANewMessage: IRwEWSEMail);
var
i: Integer;
FileName, HtmlSource: string;
Attachment: IRwEWSFileAttachment;
begin
ANewMessage.ToRecipients.AsString := edtTo.Text;
ANewMessage.CcRecipients.AsString := edtCC.Text;
if FReplyRecips <> '' then
ANewMessage.ReplyTo.AsString := FReplyRecips;
ANewMessage.Subject := edtSubject.Text;
if pcMain.ActivePage = tsPlainText then
begin
ANewMessage.Body.BodyType := btText;
ANewMessage.Body.Value := PlainTxtMessagText.Lines.Text;
end else
if pcMain.ActivePage = tsHTML then
begin
ANewMessage.Body.BodyType := btHTML;
ANewMessage.Body.Value := GetHTML(False);
HtmlSource := LowerCase(ANewMessage.Body.Value); // for attachment processing
end;
// Add the attachments
ANewMessage.Attachments.Clear;
for i := 0 to lvAttachments.Items.Count - 1 do
begin
FileName := TAttachment(lvAttachments.Items[i].Data).FileName;
Attachment := ANewMessage.Attachments.AddAttachment(FileName);
Attachment.Name := TAttachment(lvAttachments.Items[i].Data).DisplayName;
end;
end;
Screenshot:
![]() |