Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

"Set MAPISession" getting error

Posted on 2009-07-08
6
Medium Priority
?
442 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

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

Accepted Solution

by:
Chuck Wood earned 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

610 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