Solved

"Set MAPISession" getting error

Posted on 2009-07-08
6
433 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
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.

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

733 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