Send HTML Message

This application demonstrates how:

  1. How to logon to an EWS Session using a profile.
  2. How to force the profile selection dialog.
  3. How to create and send a HTML email.
  4. How to save a message
  5. How to use inline images in the HTML body.
  6. How to set a replyto recipient
  7. How to use the addressbook dialog to select recipients
  8. 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:


Back to Examples