Potrzebuję wyciągnąć adres email z Address Global List w Outlooku. Oto kod (znaleziony gdzieś w sieci):
procedure TForm1.Button2Click(Sender: TObject);
var
OutlookApp, MapiNamespace, AddrList, AddressEntries: Variant;
AddrEntry: string;
begin
//Get the Outlook Application object.
OutlookApp := CreateOleObject('Outlook.Application');
//Get the MAPI NameSpace object.
MapiNamespace := OutlookApp.GetNameSpace('MAPI');
AddrList := MapiNamespace.AddressLists('Global Address List');
AddressEntries := AddrList.AddressEntries;
try
try
Memo1.Lines.Clear;
AddrEntry := AddressEntries.GetFirst;
repeat
Memo1.Lines.Add(AddrEntry);
AddrEntry := AddressEntries.GetNext;
until false;
except
// we must be at the end
end;
finally
Memo1.Lines.Add(AddrEntry);
OutlookApp := NULL;
end;
end;
Linijka:
AddrList := MapiNamespace.AddressLists('Global Address List');
powoduje taki błąd:
Project Project1.exe raised exception class EOleException with message 'Próba wykonania operacji nie powiodła się. Nie można odnaleźć obiektu'.
Czy może tu mieć znaczenie język systemu?
Mój system to Windows 7, mam zainstalowany Outlook 2010 (razem z pakietem Office) i jest on włączony.