error 429 Cannot create Outlook object

Hi,

This code work perfect, but now for some reason i get an error 429, Cannot create outlook object. I try to find an answer, but i never found. It's like a dll or registry problem, any Idea?
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.GetOutlook()
        Me.SendMessage()

    End Sub
    ' Declare module level variables
    Dim mOutlookApp As Microsoft.Office.Interop.Outlook.Application
    Dim mNameSpace As Microsoft.Office.Interop.Outlook.NameSpace
    Dim mFolder As Microsoft.Office.Interop.Outlook.MAPIFolder
    Dim mItem As Microsoft.Office.Interop.Outlook.MailItem
    Dim fSuccess As Boolean

    ' Module contains only 2 methods:  
    '    1) GetOutlook() 
    '    2) SendMessage() 
    ''
    Public Function GetOutlook() As Boolean
        ' The GetOutlook() function sets the Outlook Application 
        ' and Namespase objects and opens MS Outlook
        On Error Resume Next

        ' Assume success
        fSuccess = True

        mOutlookApp = GetObject("", "Outlook.aplication")

        ' If Outlook is NOT Open, then there will be an error. 
        ' Attempt to open Outlook

        If Err.Number > 0 Then
            Err.Clear()
            mOutlookApp = CreateObject("Outlook.aplication")

            If Err.Number > 0 Then
                MsgBox(Err.Number)
                MsgBox("Could not create Outlook object", vbCritical)
                fSuccess = False
                Exit Function
            End If
        End If

        ' If we've made it this far, we have an Outlook App Object 
        ' Now, set the NameSpace object to MAPI Namespace
        mNameSpace = mOutlookApp.GetNamespace("MAPI")

        If Err.Number > 0 Then
            MsgBox("Could not create NameSpace object", vbCritical)
            fSuccess = False
            Exit Function
        End If

        ' Return the Success Flag as the value of GetOutlook()
        GetOutlook = fSuccess

Open in new window

LVL 1
joyacv2Asked:
Who is Participating?
 
nffvrxqgrcfqvvcCommented:
<< mOutlookApp = GetObject("", "Outlook.aplication")>>
When you say you corrected this did you correctly spell it because your example only has one (p) in the word application.
Can you remove the On Error Resume next call and replace it with Try Catch instead.
mOutlookApp = GetObject("", "Outlook.aplication")
Try using:

Imports System.Runtime.InteropServices

Try
mOutlookApp = Marshal.GetActiveObject("Outlook.Application")
Catch ex As Exception
console.writeline(ex.message)
End Try

or

mOutlookApp = GetObject(, "Outlook.Application")

 
0
 
tbsgadiCommented:
Which version of Outlook?
0
 
joyacv2Author Commented:
hi,

Outlook 2007
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
tbsgadiCommented:
Did it stop working when you upgraded to 2007 or have you had it working with 2007?

0
 
joyacv2Author Commented:
Hi,

The problems occurs suddenly. This code works perfect, maybe i change something during adapting with my program. But I wrote the original code again and the problem appears. I really think that something happens in the registry during the modification. Any idea?
0
 
joyacv2Author Commented:
Hi,

One of the changed line was the Outlook.aplication, by error. But i correct that. Maybe here is the problem. This cause something crazy when try to run the code. After that the code, sends this 429 error.
0
 
tbsgadiCommented:
Have a look at the following:

http://support.microsoft.com/kb/828550

Gary
0
 
joyacv2Author Commented:
Hi,

I check this site and did step by step and the problem continues.
0
 
David LeeCommented:
The word "application" is misspelled as "aplication" on lines 25 and 32.  Correct the spelling and the code should work.
0
 
joyacv2Author Commented:
Thank You! This solve my problem!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.