Send Plaintext Message

This application demonstrates how:

  1. How to logon to an EWS Session using a profile.
  2. How to create and send a plainttext email.
  3. How to add attachments to email messages.

Example code:


  // Logon, create and send the message
  EWSSession.Active := True;
  try
    Screen.Cursor := crHourGlass;
    NewMessage := EWSSession.CreateMessage(dfinDrafts) as IRwEWSEMail;

    NewMessage.ToRecipients.AsString := edtTo.Text;
    NewMessage.Subject               := edtSubject.Text;
    NewMessage.BodyText              := msgBody.Text;
    NewMessage.Importance            := icHigh;

    // Add the selected attachments
    for i := 0 to lvAttachments.Items.Count-1 do
      NewMessage.Attachments.AddAttachment(lvAttachments.Items[i].Caption);

    // Submit the message
    NewMessage.SubmitMessage(True);
  finally
    Screen.Cursor := crDefault;
    EWSSession.Active := False;
  end;

Screenshot:


Back to Examples