BooBoo2004
asked on
oleobject.ConnectToNewObject("Outlook.Application") fails with a -3 return code
I am using the Outlook Redemption dll for my email application. When I try to connect via the ConnectToNewObject("Outloo k.Applicat ion"), I get a -3 return code. I guess that this means that the object could not be created. The code that I am using is:
oleOutlook = create oleobject
rc = oleOutlook.ConnectToNewObj ect("outlo ok.applica tion")
If rc = 0 Then
oleNameSpace = oleOutlook.GetNameSpace("M API")
oleNameSpace.Logon("", "", true, true)
oleSafeMailItem = create oleobject
rc = oleSafeMailItem.ConnectToN ewObject(" Redemption .SafeMailI tem")
If rc = 0 Then
oleTmp = create oleobject
oleTmp = oleOutlook.CreateItem(0)
oleSafeMailItem.Item = oleTmp
oleSafeMailItem.Recipients .Add(ls_se ndto)
oleSafeMailItem.Recipients .ResolveAl l
oleSafeMailItem.Subject = ls_subject
oleSafeMailItem.Send
Else
MessageBox("Mail Error", &
"Your email could not be sent. Please contact IT.~r~n" + &
"The SafeMailItem - ConnectToNewObject~r~n" + &
"failed with a return code of " + String(rc) + ".", &
StopSign!, &
Ok!)
End If
Else
MessageBox("Mail Error", &
"Your email could not be sent. Please contact IT.~r~n" + &
"The Outlook Application - ConnectToNewObject~r~n" + &
"failed with a return code of " + String(rc) + ".", &
StopSign!, &
Ok!)
End If
If I change the Outlook.Application with Word.Application, the connecttonewobject works fine. I think that this may be a registry problem. When I compare Outlook.Application to the Word.Application registry values, I do not see the key VersionIndependentProgID for Outlook. I added it, but it still did not work. I would like to get this fixed ASAP.
I am using PB10, Windows 2000, Outlook 2003 (Mail server is Exchange), and the latest Redemption dll.
oleOutlook = create oleobject
rc = oleOutlook.ConnectToNewObj
If rc = 0 Then
oleNameSpace = oleOutlook.GetNameSpace("M
oleNameSpace.Logon("", "", true, true)
oleSafeMailItem = create oleobject
rc = oleSafeMailItem.ConnectToN
If rc = 0 Then
oleTmp = create oleobject
oleTmp = oleOutlook.CreateItem(0)
oleSafeMailItem.Item = oleTmp
oleSafeMailItem.Recipients
oleSafeMailItem.Recipients
oleSafeMailItem.Subject = ls_subject
oleSafeMailItem.Send
Else
MessageBox("Mail Error", &
"Your email could not be sent. Please contact IT.~r~n" + &
"The SafeMailItem - ConnectToNewObject~r~n" + &
"failed with a return code of " + String(rc) + ".", &
StopSign!, &
Ok!)
End If
Else
MessageBox("Mail Error", &
"Your email could not be sent. Please contact IT.~r~n" + &
"The Outlook Application - ConnectToNewObject~r~n" + &
"failed with a return code of " + String(rc) + ".", &
StopSign!, &
Ok!)
End If
If I change the Outlook.Application with Word.Application, the connecttonewobject works fine. I think that this may be a registry problem. When I compare Outlook.Application to the Word.Application registry values, I do not see the key VersionIndependentProgID for Outlook. I added it, but it still did not work. I would like to get this fixed ASAP.
I am using PB10, Windows 2000, Outlook 2003 (Mail server is Exchange), and the latest Redemption dll.
ASKER
I changed it to outlook.application.11 and still get the same error. I have not tried it on another machine as I am the only developer here.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
rc = oleOutlook.ConnectToNewObj
you could've if
if connecttonewobject(outlook
connecttonewobject(outlook
. I tested your code its working. Did you try this in some other machine ?