Reputation: 15384
In this question I just asked I told that I prepare Outlook messages by sending data from my app to Outlook with MAPI.
But in this way I have one major hurdle: I cannot send formatted text for the message body. My form has an rtf field, I strip away rtf data then prepare the outlook mail.
How is it possible to do the same (creating an outlook outgoing email ready to be sent) without using mapi, and keeping the formatting, somehow "rtf to html"... Does anyone already have this code?
Upvotes: 3
Views: 7974
Reputation: 1610
You can use Microsoft's Collaboration Data Objects but it is limited by the Outlook Security Patch. The Redemption Data Objects that are part of Outlook Redemption works around the Security patch. I have used RDO to create RTF emails in Outlook.
Here is a sample procedure using RDO to create an email, insert RTF formatted text and display the email so it can be edited before sending.
procedure TForm1.RTFemail;
var
Session, Drafts, Mail, Recip: OleVariant;
s : string;
begin
Session := CreateOleObject('Redemption.RDOSession');
Session.Logon;
Drafts := Session.GetDefaultFolder(olFolderDrafts);
Mail := Drafts.Items.Add;
Recip := Mail.Recipients.Add('[email protected]');
Recip.Type := olTo;
Recip.Resolve;
Mail.Subject := 'Testing Redemption';
s := '{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil'+
'\fcharset0 Arial;}}\viewkind4\uc1\pard\fs16 This is \ul '+
'underlined\ulnone , \i italic\i0 , and \b bold\b0 .\par }';
Mail.RTFBody := s;
Mail.Save;
Mail.Display;
end;
It produces the following with Outlook 2003
Upvotes: 3
Reputation: 19346
Using the Ole Automation Server component wrappers provided by Delphi. An example I dug up for another question recently can be found here: Easiest way to compose Outlook 2010 mail from Delphi?
Upvotes: 4