How to read email from Exchange in VB
Posted on 2004-08-02
I have a developer who needs to automatically process an Excel attachment that is emailed daily. He is currently using the Outlook object model to do this. A job runs his VB executable every few minutes to check to see if the email is available. This executable runs on a server that also runs SQL Server and is looking for the email in a profile that is set up on the server.
Frequently, an instance of the OUTLOOK.EXE opened by the VB app does not close properly and continues running until we physically kill it. This is a problem because the running instance of Outlook interferes with SQL Server's ability to send notifications. I do not consider a process to check for Outlook and kill it to be a good solution for this problem.
I did some research on this site and Google and saw several references to using MAPI instead of Outlook to do this type of function. Is this a good solution? If so, code samples on how to access the mail server, read the email and save the attachment would be appreciated. I am only a minimal VB programmer and the developer is not familiar with MAPI. If not, could I get some suggestions on how to prevent the stranded Outlook process?