I'm working with Delphi2010 . When I run the code with Outlook 2003 SP3, I get no errors but on another pc with outlook2007 i get an error 'Invalid Function error'.
const
olMailItem = 0;
olFolderInbox = $00000006;
var
Outlook: OleVariant;
oNameSpace: OleVariant;
oFolder: Olevariant;
oMailItem: Variant;
oUserProperty: Olevariant;
begin
try
Outlook := GetActiveOleObject('Outlook.Application');
except
Outlook := CreateOleObject('Outlook.Application');
end;
oNameSpace := Outlook.GetNamespace('MAPI') ;
oFolder:= oNameSpace.GetDefaultFolder(olFolderInbox);
oMailItem := Outlook.CreateItem(olMailItem);
...
oUserProperty:= oMailItem.UserProperties.Add('RetrieveCode', 1); //--> get error on Outlook2007
oUserProperty.Value:=ARetrieveCode;
...
end;
When I use redemption I get the same error for Outlook2007 Can someone point the right direction to solve this problem?
I catch the error with eurekalog:
; ComObj (Line=0 - Offset=0)
; --------------------------
00538469 mov eax, dword ptr [EOleSysError]
0053846E call ComObj
00538473 mov esi, eax
00538475 cmp dword ptr [ebp-$04], +$00
00538479 jz ComObj
0053847B push dword ptr [ebp-$04]
0053847E mov eax, esi
00538480 jmp System
00538485 jmp ComObj
00538487 mov eax, esi
00538489 call System ; <-- EXCEPTION
0053848E xor eax, eax
00538490 pop edx
00538491 pop ecx
00538492 pop ecx
00538493 mov fs:[eax], edx
00538496 push $005384B0 ; '^[‹å]Â.'
0053849B lea eax, [ebp-$10]
0053849E mov edx, $00000003 ; ''...
005384A3 call System
005384A8 ret