Examples Delphi

USES [..],
Outlook8, OleServer, COMobj, ActiveX;
[..]
procedure TfrmKuProt.sbtMailClick(Sender: TObject);
VAR
Outlook : OutlookApplication;
Unknown : IUnknown;
Result : HResult;
MI : MailItem;
Insp : Inspector;
x : Integer;
aExportFilter: TQRExportFilter;
wmf : TQRWMFFilter;
CONST
olMailItem = 0;
BEGIN
qr.Prepare;
try
wmf := TQRWmfFilter.Create(NIL);
wmf.Enhanced := TRUE;
aExportFilter := TQRExportFilterLibraryEntry(
QRExportFilterLibrary.Filters[4]).ExportFilterClass.Create('c:\rpt.bmp');
qr.QRPrinter.ExportToFilter(aExportFilter);
wmf.Free;
finally
aExportFilter.Free
end;
// via early binding:
Result := GetActiveObject(CLASS_OutlookApplication, nil, Unknown);
if Result = MK_E_UNAVAILABLE then
Outlook := CoOutlookApplication.Create
else begin
// make sure no other error occurred during GetActiveObject
OleCheck(Result);
OleCheck(Unknown.QueryInterface(OutlookApplication, Outlook));
end;
MI := Outlook.CreateItem(olMailItem) as MailItem;
MI.Recipients.Add(' @');
MI.Attachments.Add('c:\rpt.bmp',EmptyParam, EmptyParam, EmptyParam);
MI.Subject := 'Your sheet Y';
MI.Body := 'Dear Mr. Dredd,'#13#10#13#10'Enclosed please find ..'#13#10;
Insp := MI.GetInspector;
Insp.Display(False);
Showmessage('Please click OK when Outlook is finished.');
Screen.Cursor := crHourglass;
Outlook.Quit;
Outlook := nil;
end;
Thanks to Deborah Pate (see her URL on my Delphi Tips page) for pointing me in the right direction with Outlook.