问题
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?
回答1:
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?
回答2:
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('nobody@gmail.com');
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
回答3:
Exchange Web Services (EWS) were introduced in Exchange 2007 as an alternative to the MAPI protocol, it is a documented SOAP based protocol.
I guess it will not launch or activate the Outlook client but it is be possible to create a new E-mail message in the "Draft" folder (see CreateItem refrence).
The Body element documentation shows that plain text and HTML are supported.
来源:https://stackoverflow.com/questions/4907158/delphi-how-to-compose-an-email-in-outlook-without-using-mapi