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 use inline images in the HTML body.
Example code:
// Setup the session so that it will ask the user for a profile
EWSSession.ProfileName := '';// EWSProfile.DefaultProfileName
EWSSession.ProfileRequired := True;
EWSSession.LogonDialog := True;
// Logon, create and send the message
EWSSession.Active := True;
try
// create a new message of class IPM.Note in the drafts folder of the default messagestore
NewMessage := EWSSession.CreateMessage(dfinDrafts) as IRwEWSEMail;
NewMessage.ToRecipients.AsString := edtTo.Text;
NewMessage.Subject := edtSubject.Text;
NewMessage.BodyText := msgBody.Lines.Text;
// Add the attachment for the table background
Logo := TMemoryStream.Create;
try
RwDecodeBase64(RawByteString(memoBase64EncodedLogo.Lines.Text), Logo);
Logo.Position := 0;
Att := NewMessage.Attachments.AddAttachment('Logo.gif', 'image/gif', Logo);
Att.ContentId := '_Logo';
{$IFDEF EXCHANGE2010}
Att.IsInline := True; // this will hide the paperclip
{$ENDIF EXCHANGE2010}
finally
Logo.Free;
end;
// Submit the message
NewMessage.SubmitMessage(True);
finally
EWSSession.Active := False;
end;
Screenshot: