Error reading Outlook folder

PatrickTingen

New Member
We are in a process of migrating our servers and we are strugging with a mail problem.

Old server: windows server 2012R2, Progress 11.2, Outlook 2013
New server: windows server 2019 Data Center, Progress 11.7, Outlook 2019

What we do is running a progress program via the task scheduler to save mail attachments to disk. These are then picked up by another program to be processed. This works like a charm on the old server, but migrating all code to the new results in errors. The stripped version of the program is as follows:

Code:
DEFINE VARIABLE hOutlook     AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hNameSpace   AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hRecipient   AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hInbox       AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hFolder      AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE cMailAccount AS CHARACTER  NO-UNDO INITIAL "Productie".
DEFINE VARIABLE cFolder      AS CHARACTER  NO-UNDO INITIAL "Orders".

&GLOBAL-DEFINE olFolderInbox  6

/* Start Outlook */
CREATE "Outlook.Application" hOutlook.
IF NOT VALID-HANDLE(hOutlook) OR ERROR-STATUS:ERROR THEN RETURN "Cannot start Outlook".

/* Open mailbox */
hNameSpace = hOutlook:GetNameSpace("MAPI").
hRecipient = hNameSpace:CreateRecipient(cMailAccount) NO-ERROR.
IF NOT VALID-HANDLE(hRecipient) OR ERROR-STATUS:ERROR THEN RETURN "Cannot init recipient".
hRecipient:resolve().

/* Find inbox */
hInbox = hNameSpace:GetSharedDefaultFolder(hRecipient, {&olFolderInbox}) NO-ERROR.
IF NOT VALID-HANDLE(hInbox) THEN RETURN "Cannot find inbox".
 
/* Find "Orders" folder in the inbox */
hFolder = hInbox:Folders(cFolder). /* [B]*ERROR*[/B] */

MESSAGE
  "hInbox:          " hInbox SKIP
  "hInbox:Folders   " hInbox:Folders SKIP
  "hInbox.FolderPath" hInbox:FolderPath VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.

We receive this error:

2vr3bb9.png


And then see this message:

M8PANn0.png


We tested this in both 32 and 64 bit version of Progress. See the line with comment *ERROR* where it fails. We get the attached error. But the variables seem to have the correct value (image 2). We suspect that it has something to do with the security settings of Outlook, we checked the trust center but can't find anything that seems to be wrong, however, the program still does not work.

Any tips?
 
Last edited:

Cecil

19+ years progress programming and still learning.
It's a long shot, but when I tried your code I got presented with this warning message. Is this something that you get?

1682372015924.png
 

MarkW

New Member
Ah 5890, one of those helpful ActiveX errors (we've had plenty of those during our migration to v12 and new Windows servers).
In our case we had some long forgotten dlls which needed copying and re-registering.
 

Cecil

19+ years progress programming and still learning.
Ah 5890, one of those helpful ActiveX errors (we've had plenty of those during our migration to v12 and new Windows servers).
In our case we had some long forgotten dlls which needed copying and re-registering.
I think just have MS Office installed will be sufficient. When I have time will look at the .NET equivariant of the COM Automation.

I have already develop code that interacts with Office365 via Microsoft Graph API. But this is out of scope of what is required by Patrick.
 
Last edited:

PatrickTingen

New Member
Ah 5890, one of those helpful ActiveX errors (we've had plenty of those during our migration to v12 and new Windows servers).
In our case we had some long forgotten dlls which needed copying and re-registering.
I don't think this is the issue; we can connect to Outlook without any problem, it fails when we try to access the "Folders" property. We are pretty sure it had something to do with permissions / authorization. When we try to read our own (a non-shared) mailbox it works fine.
 
Top