Registriert seit: 10. Nov 2003
3 Beiträge
Delphi 2005 Personal
|
ADO und Exchange
8. Apr 2006, 12:17
Datenbank: ADO • Zugriff über: Nativer CreateOleObject Zugriff auf ADO Objekte
Hallo!
Ich versuche auf die Kalendereinträge innerhalb von MS Exchange (2000 und 2003) über den ADO Exchange Provider (ExOLEDB) zu zugreifen. Leider gelingt mir dies nicht und ich bekomme unterschiedliche OLE Fehlermeldungen.
Kann mir jemand einen Tipp geben, wie ich das anstellen kann?
Ich nutze Delphi 2005 PE.
Anbei mein Sourcecode (etwas chaotisch...).
Herzlichen Dank!
Delphi-Quellcode:
unit WebCalendarUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleServer, ComObj;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
Var
CalendarURL, ConnProvider : String;
oConn, oRs, oRec, TempRS : OleVariant;
sQuery: String;
i,j: integer;
begin
//CalendarURL := 'file://./backofficestorage/ComputerDomain/MBX/Mailalias/Kalender';
CalendarURL := ' http://ExchangeServer/exchange/Mailalias/kalender/';
ConnProvider := ' ExOLEDB.DataSource';
oConn := CreateOleObject(' ADODB.Connection');
oRs := CreateOleObject(' ADODB.Recordset');
oRec := CreateOleObject(' ADODB.Record');
oConn.Provider := ConnProvider;
oConn.Open(CalendarURL, , , 1);
//oRec.Open(CalendarURL, , , );
//oRs.ActiveConnection := oRec.ActiveConnection;
sQuery := ' SELECT "DAV:href", "urn:schemas:httpmail:subject", "urn:schemas:calendar:dtstart", "urn:schemas:calendar:dtend",'
+ ' "urn:schemas:calendar:duration", "DAV:Categories", "http://schemas.microsoft.com/exchange/keywords-utf8",'
+ ' "http://schemas.microsoft.com/exchange/intendedbusystatus", "urn:schemas:calendar:organizer", "DAV:contentclass" '
+ ' FROM scope('' shallow traversal of "' + CalendarURL + ' "'' ) WHERE ("DAV:ishidden" = False) AND'
+ ' ("DAV:contentclass" = '' urn:content-classes:appointment'' ) AND ("urn:schemas:calendar:dtstart" >= '' 2006/01/01 00:00:00'' )'
+ ' ORDER BY "urn:schemas:calendar:dtstart" ASC';
oRs.Open(, oConn, 1, , );
//ShowMessage(Conn.Version);
//oRs.Source := sQuery;
Try
//oRs.Open(,oConn,,,);
except
on e: EOleException do begin
ShowMessage(e.Source);
ShowMessage(e. Message);
//ShowMessage(e.ErrorCode);
ShowMessage(e.helpfile);
ShowMessage(IntToStr(e.HelpContext));
end;
end;
//ShowMessage(Conn.Errors.Item[0].Description);
//oRS.Open(sQuery, oConn,,);
oRs := oConn.Execute(sQuery);
//oRS := oConn.Execute(sQuery);
//Rs.ActiveConnection := Rec.ActiveConnection;
//Rs.Source := ''SELECT ''DAV:href'', ' ' ''urn:schemas:httpmail:subject'', ' ' ''urn:schemas:calendar:dtstart'', ' ' ''urn:schemas:calendar:dtend'', ' ' ''urn:schemas:calendar:duration'', ' ' ''DAV:Categories'', ' ' ''http://schemas.microsoft.com/exchange/keywords-utf8'', ' ' ''http://schemas.microsoft.com/exchange/intendedbusystatus'', ' ' ''urn:schemas:calendar:organizer'', ' ' ''DAV:contentclass'' ' 'FROM scope('shallow traversal of ''' & CalendarURL & '''') ' 'WHERE (''DAV:ishidden'' = False)' ' AND (''DAV:contentclass'' = 'urn:content-classes:appointment')' ' ORDER BY ''urn:schemas:calendar:dtstart'' ASC'
//Rs.Open;
If oRs.RecordCount <> 0 then
begin
oRs.MoveFirst;
While not oRs.eof do
begin
ShowMessage(' Data Set found!');
end;
end;
end;
end.
|