[eluser]MrBaseball34[/eluser]
Code:
oXMLHTTP and oXMLDoc are defined as:
oXMLDoc: IXMLDOMDocument2;
oXMLHTTP: IXMLHTTPRequest;
and created in the formcreate like this:
oXMLDoc := CreateOleObject('MSXML2.DOMDocument.3.0') as IXMLDOMDocument2;
oXMLHTTP := CreateOleObject('MSXML2.XMLHTTP') as IXMLHTTPRequest;
GET_AB_DATA and AB_UA consts are defined as:
const
GET_AB_DATA = '<?xml version="1.0"?>'+
'<D:propfind xmlns:D="DAV:" '+
' xmlns:h="http://schemas.microsoft.com/hotmail/" '+
' xmlns:c="urn:schemas:contacts:">'+
' <D:prop>'+
' <D:id/>'+
' <c:group/>'+
' <h:modified/>'+
' <c:cn/>'+
' <c:givenName/>'+
' <c:sn/>'+
' <c:nickname/>'+
' <c:mail/>'+
' <c:homeStreet/>'+
' <c:homeCity/>'+
' <c:homeState/>'+
' <c:homePostalCode/>'+
' <c:homeCountry/>'+
' <c:o/>'+
' <c:street/>'+
' <c:l/>'+
' <c:st/>'+
' <c:postalcode/>'+
' <c:co/>'+
' <c:homePhone/>'+
' <c:homeFax/>'+
' <c:telephoneNumber/>'+
' <c:facsimiletelephonenumber/>'+
' <c:mobile/>'+
' <c:otherTelephone/>'+
' <c:bday/>'+
' <c:pager/>'+
' </D:prop>'+
'</D:propfind>';
AB_UA = 'Windows-Address-Book/6.0 '+
'(MSIE 6.0; Windows NT 5.1; '+
'Installed by Symantec Package; SV1; '+
'Embedded Web Browser from: http://bsalsa.com/; '+
'.NET CLR 2.0.50727; .NET CLR 1.1.4322; InfoPath.1; '+
'.NET CLR 3.0.04506.648; .NET CLR 3.5.21022)';
procedure TfmHotmailForm.GetABData;
var
oElement : IXMLDOMElement;
oNodeList : IXMLDOMNodeList;
sl: TStringList;
begin
if (Length(FUsername) = 0) then
oXMLHTTP.open('PROPFIND', FContactsURL, False, '', '')
else
oXMLHTTP.open('PROPFIND', FContactsURL, False, FUsername, FPassword);
oXMLHTTP.setRequestHeader('PROPFIND',
GET_AB_DATA);
oXMLHTTP.setRequestHeader('Content-Type',
'text/xml');
oXMLHTTP.setRequestHeader('Depth', '0');
oXMLHTTP.setRequestHeader('User-Agent',
AB_UA);
oXMLHTTP.send(EmptyParam);
(*
There seems to be a problem getting this data now as, on the redirect, the HTTPMail
control is switching UserAgents and we get a X-Dav-Error: 801 Invalid User-Agent
*)
FResponseHdrs := oXMLHTTP.getAllResponseHeaders;
FResponseText := oXMLHTTP.ResponseText;
oXMLDoc.LoadXML(FResponseText);
Result := oXMLDoc.childNodes.length > 0;
if Result then
begin
oElement := oXMLDoc.documentElement;
oNodeList := oElement.childNodes;
if oNodeList.length > 0 then
begin
// iterate through the nodes to get the data. See daata example below
end;
end;
end;