Solved

"Set MAPISession" getting error

Posted on 2009-07-08
6
429 Views
Last Modified: 2013-11-27
I'm getting a error when trying to send out e-mail.  The error occurs on line below:
  Set MAPISession = CreateObject("MAPI.Session")
See code below for entire subroutine

Error Number: 429
Description: ActiveX component can't create object

This computer got screwed up with a faulty installation disk that remove a bunch of stuff.  I think my mapi stuff got removed.  How do I fix it?
Private Sub StartMessagingAndLogon()
    Dim sKeyName As String
    Dim sValueName As String
    Dim sDefaultUserProfile As String
    Dim osinfo As OSVERSIONINFO
    Dim retvalue As Integer
    
    On Error GoTo ErrorHandler
    Set MAPISession = CreateObject("MAPI.Session")
    
    'Try to log on.  If this fails, the most likely reason is
    'that you do not have an open session.  The error
    '-2147221231  MAPI_E_LOGON_FAILED returns.  Trap
    'the error in the ErrorHandler.
    MAPISession.Logon ShowDialog:=False, NewSession:=False
    Exit Sub
 
ErrorHandler:
    Select Case Err.Number
       Case -2147221231  'MAPI_E_LOGON_FAILED
          'Need to determine what operating system is in use. The keys are different
          'for WinNT and Win95.
          osinfo.dwOSVersionInfoSize = 148
          osinfo.szCSDVersion = Space$(128)
          retvalue = GetVersionEx(osinfo)
          Select Case osinfo.dwPlatformId
             Case 0   'Unidentified
                LogEvt "Unidentified Operating System.  Cannot log on to messaging.", vbCritical, "Email Problem (ASO-3)"
                Exit Sub
             Case 1   'Win95
                sKeyName = "Software\Microsoft\" & _
                           "Windows Messaging " & _
                           "Subsystem\Profiles"
    
             Case 2   'NT
                 sKeyName = "Software\Microsoft\Windows NT\" & _
                            "CurrentVersion\" & _
                            "Windows Messaging Subsystem\Profiles"
          End Select
    
          sValueName = "DefaultProfile"
          sDefaultUserProfile = QueryValue(sKeyName, sValueName)
          MAPISession.Logon ProfileName:=sDefaultUserProfile, _
                           ShowDialog:=False
          Exit Sub
       Case Else
          LogEvt "An error has occured while trying" & Chr(10) & _
          "to create and to log on to a new ActiveMessage session." & _
          Chr(10) & "Report the following error to your " & _
          "System Administrator." & Chr(10) & Chr(10) & _
          "Error Location: frmMain.StartMessagingAndLogon" & _
          Chr(10) & "Error Number: " & Err.Number & Chr(10) & _
          "Description: " & Err.Description, vbCritical, "Email Problem (ASO-4)"
    End Select
End Sub

Open in new window

0
Comment
Question by:schmir1
  • 4
  • 2
6 Comments
 
LVL 16

Expert Comment

by:Chuck Wood
ID: 24808553
Where do you define OSVERSIONINFO?
0
 

Author Comment

by:schmir1
ID: 24814481
See below.  I can send you the entire module if that would help.
Private Type OSVERSIONINFO
    dwOSVersionInfoSize As Long
    dwMajorVersion As Long
    dwMinorVersion As Long
    dwBuildNumber As Long
    dwPlatformId As Long
    szCSDVersion As String * 128
End Type

Open in new window

0
 

Author Comment

by:schmir1
ID: 24882658
Anyone have any ideas?
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

Author Comment

by:schmir1
ID: 24910819
I guess I will close this question???
0
 
LVL 16

Accepted Solution

by:
Chuck Wood earned 500 total points
ID: 24913741
I think you need to declare the MAPISession as an Object before you Set it.
-Chuck
    Dim MAPISession As Object
    On Error GoTo ErrorHandler
    Set MAPISession = CreateObject("MAPI.Session")

Open in new window

0
 

Author Comment

by:schmir1
ID: 24956791
Thanks.  I'm running my code on my PC that works so I don't need to do your suggestion right way.  I'll assume it works.
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question