Solved

"Set MAPISession" getting error

Posted on 2009-07-08
6
426 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now