MAPI Problem

Hi,

I downloaded the MAPI code that allows for multiple attachments. I ran the program and it created an e-mail message in my Outbox. The problem is that when I tried to run it again I get a Progress error telling me that it cannot find windows.i. It seems to make a mess of my path. Any ideas why this happens?

Stuart Richler
stuart@gtrdta.com


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jurjen's picture

re: MAPI problem

Hi Stuart, can you verify that the working directory before the call is identical to the working directory after the call?
I see nothing in the code that modifies the working directory, but I can imagine that you may have added a user interface where the user can launch a fileselect dialog to pick the attachments, and this dialog may perhaps be modifying the working directory.

In general, my opinion is that code should not ever try to change the working directory (unless the code happens to be an installer or something similar), but just to make sure I also recommend to never use relative paths in the Propath.


MAPI Problem

I looked at the propath before and after and they looked the same. I used the code pretty much as is without any user interface. The only thing I modified in the code was to remove the nested procedure calls. I was not able to run it with the nested call. Perhaps my Progress version doesn;t allow for nested calls? Anyway, I can send you the code that I used if you want.

Stuart Richler
www.gtrdata.com
stuart@gtrdata.com


Problem Solved

I found an article in the Progress KB that addresses this very issue. Needless to say I implemented the solution and everything works fine now. Thanks for your help.

ID: P40890
Title: "The creation of a MAPI SESSION changes the working directory of Progress to the MAPI executable directory."

Created: 09/05/2003 Last Modified: 09/05/2003
Status: Unverified

Symptoms:

Using the Microsoft MAPI Control from Progress 4GL.
Calling the MAPISendMail function in MAPI32.DLL using the Progress DLL interface.
The working directory changes without any warning.

Changes:
Installed Microsoft Outlook 2000 or Internet Explorer 5.

Cause:
This is a Microsoft issue with the MAPI32.DLL.

Fixes:
In order to maintain the default directory and still use MAPI functionality, store the current directory into a local variable before doing MAPI processing. Then, after the completion of MAPI processing, set the working directory back to what it was using the value stored in the defined local variable. e.g.:

DEFINE VARIABLE szOriginalDirectory AS CHARACTER.
FILE-INFO:FILE-NAME = ".".
szOriginalDirectory = FILE-INFO:FULL-PATHNAME.
/* do MAPI stuff */
RUN SetCurrentDirectoryA(szOriginalDirectory).
PROCEDURE SetCurrentDirectoryA EXTERNAL "kernel32.dll":U:
DEFINE INPUT PARAMETER newdir AS CHAR.
END.

Notes:
References to Written Documentation:

Microsoft KBase articles:

Q269170 PRB: Set of DEFAULT Changed After MAPI.SESSION Logon
Q245557 PRB: Current Directory Changes After OL2000 Installation
Q244343 PRB: Microsoft MAPI Control Changes the Current Working Directory

Stuart Richler
www.gtrdata.com
stuart@gtrdata.com