ConnectTo method with Simple MAPI -- VB6?

Add-in Express™ Support Service
That's what is more important than anything else

ConnectTo method with Simple MAPI -- VB6?
ConnectTo method with Simple MAPI? 
Wade Prince




Posts: 4
Joined: 2006-04-02
I installed OSM so that my legacy VB6 application will work with Outlook 2003. The VB6 application uses the Simple MAPI controls MapiSession and MapiMessages to send email.

The OSM appears to work most of the time, but sometimes it will just stop working.

I open Microsot Outlook 2003 first then I run my standalone VB6 application.
When I start the VB6 application, it first gets a SessionID with this code:
MAPISession1.SignOn

Then code later on in the program sends the email like this:
MAPIMessages1.SessionID = MAPISession1.SessionID
OutlookSecurityManager1.DisableSMAPIWarnings = True
MAPIMessages1.Compose
MAPIMessages1.MsgSubject = ...
MAPIMessages1.MsgNoteText = ...
MAPIMessages1.Send (False)
OutlookSecurityManager1.DisableSMAPIWarnings = False

This works most of the time, but last night OSM stopped working. I had to shutdown and restart Outlook and my email application to get it working again.

Is my code missing something? I'm not using the ConnectTo method at all. Do I need to use the ConnectTo method in OSM with SimpleMAPI in VB6? If so, how do I do this?

Much thanks.
Posted 02 Apr, 2006 10:00:51 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Wade,

The snippet of code that I can see seems to be correct. And you don't need to call the ConnectTo method. Could you please give some more information. How did your application "stop working"? Was some exception fired? Did you see security warnings?

Posted 03 Apr, 2006 07:07:56 Top
Wade Prince




Posts: 4
Joined: 2006-04-02
Hello Dmitry,
Thanks for the quick response.

My application would "stop working" when Outlook would suddenly start showing security warnings when it runs the MAPIMessages1.Send command.
I don't see any error exception fired, but the procedure uses "On Error Resume Next" for error trapping. The program checks the Err object, but not after running the OSM methods.

Should I change the code to see If I can trap any errors for OSM when using enabling or disabling it for simple MAPI?

One more think I should note. THe VB6 program only does the MAPISession "Sign On" only once - at the beginning when I start it - not before each email. Could this have anything to do with the problem?

Posted 03 Apr, 2006 10:00:23 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi,

Should I change the code to see If I can trap any errors for OSM when using enabling or disabling it for simple MAPI?


It would be great if we trapped some error. Also you can change your code like this:


If OutlookSecurityManager1.Check(osmSimpleMAPI) = osmOK Then
    OutlookSecurityManager1.DisableSMAPIWarnings = True
End If
' 
' YOUR CODE HERE
'
If OutlookSecurityManager1.DisableSMAPIWarnings = True Then
    OutlookSecurityManager1.DisableSMAPIWarnings = False
End If


Posted 03 Apr, 2006 10:13:58 Top
Wade Prince




Posts: 4
Joined: 2006-04-02
Dmitry,
I will do what you suggest and provide back to you the results.

Thanks!
Posted 03 Apr, 2006 10:22:44 Top
Wade Prince




Posts: 4
Joined: 2006-04-02
Dmitry,
No more occurences of the problem as of this morning and no unusual errors were trapped. I will say that I modified another subroutine in my application that deletes Outlook mail items from the Sent folder when it's full. That subroutine did use OSM and the Connect method to an Outlook application. I realized that OSM is not required for this and I removed the OSM code from that subroutine and no problems since. Maybe the Connect method to another Outlook application was throwing OSM off in my simple MAPI send mail routine?

Thanks for your help.
Posted 04 Apr, 2006 09:17:37 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi,

First of all I am glad everything works.

Maybe the Connect method to another Outlook application was throwing OSM off in my simple MAPI send mail routine?


I think it may cause problems if you used the same OSM instance in both routines. Is it so?

Posted 04 Apr, 2006 11:06:53 Top