473,714 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unable to create object error in sp_SendSMTPMail

Hello,

I am attempting to send emails using T-SQL (in a SQLServerAgent Job)
using the stored procedure sp_SendSMTPMail . I created the stored proc
using the following script that I got off a post here on google.

CREATE PROCEDURE sp_SendSMTPMail (@From varchar(255),
@To varchar(8000),
@Subject varchar(255),
@Body varchar(8000),
@cc varchar(8000) = NULL,
@Bcc varchar(8000) = NULL)
AS

DECLARE @newmail int
DECLARE @result int

-- Create the CDONTS.Newmail object
EXEC @result = sp_OACreate 'CDONTS.NewMail ', @newmail OUT
IF @result <> 0
BEGIN
PRINT 'Error creating object'
EXEC sp_displayoaerr orinfo @newmail, @result
RETURN
END

-- Check the Optional Properties
IF not @cc = NULL
BEGIN
EXEC @result = sp_OASetPropert y @newmail, 'cc', @cc
IF @result <> 0
BEGIN
PRINT 'Error setting [cc] property'
-- EXEC sp_displayoaerr orinfo @newmail, @result
RETURN
END
END
IF not @Bcc = NULL
BEGIN
EXEC @result = sp_OASetPropert y @newmail, 'Bcc', @Bcc
IF @result <> 0
BEGIN
PRINT 'Error setting [Bcc] property'
-- EXEC sp_displayoaerr orinfo @newmail, @result
RETURN
END
END

--set the non-optional properties
EXEC @result = sp_OASetPropert y @newmail, 'From', @From
EXEC @result = sp_OASetPropert y @newmail, 'To', @To
EXEC @result = sp_OASetPropert y @newmail, 'Subject', @Subject
EXEC @result = sp_OASetPropert y @newmail, 'Body', @Body

-- Send the message...
EXEC @result = sp_OAMethod @newmail, 'Send'
IF @result <> 0
BEGIN
PRINT 'Error sending message'
-- EXEC sp_displayoaerr orinfo @newmail, @result
RETURN
END

-- Destroy the object.
EXEC @result = sp_OADestroy @newmail
IF @result <> 0
BEGIN
PRINT'Error destroying object'
-- EXEC sp_displayoaerr orinfo @newmail, @result
RETURN
END

GO

_______________ _______________ _______________ _
This worked perfectly in testing at our office but when we shipped to
the client it produced the error 'Error creating object'. We sent the
client the script to create the sp_displayoaerr orinfo proc and got the
following error message.

Error creating object-2147221005
OLE Automation Error Information
HRESULT: 0x800401f3
Source: ODSOLE Extended Procedure
Description: Invalid class string
Now this suggested to me that the for some reason we were unable to
reference the CDO library, or it wasn't installed. However they have
Outlook 2000 installed with CDO installed with it. I've had had them
remove and reinstall the CDO library but that hasn't helped.

Other thing I though of was a permission type problem. They are using
NT authentication for there logins into SQL server and are logged on
the server as Administrator who I would assume has all required
permissions.

Any suggestions for either determining the cause of them problems or a
solution?

Thanks in advance.

Bob.
Jul 20 '05 #1
3 7061
Hi

You may want to look at:
http://www.sqldev.net/xp/xpsmtp.htm

John

"Robert Hogan" <bu*******@hotm ail.com> wrote in message
news:eb******** *************** **@posting.goog le.com...
Hello,

I am attempting to send emails using T-SQL (in a SQLServerAgent Job)
using the stored procedure sp_SendSMTPMail . I created the stored proc
using the following script that I got off a post here on google.

CREATE PROCEDURE sp_SendSMTPMail (@From varchar(255),
@To varchar(8000),
@Subject varchar(255),
@Body varchar(8000),
@cc varchar(8000) = NULL,
@Bcc varchar(8000) = NULL)
AS

DECLARE @newmail int
DECLARE @result int

-- Create the CDONTS.Newmail object
EXEC @result = sp_OACreate 'CDONTS.NewMail ', @newmail OUT
IF @result <> 0
BEGIN
PRINT 'Error creating object'
EXEC sp_displayoaerr orinfo @newmail, @result
RETURN
END

-- Check the Optional Properties
IF not @cc = NULL
BEGIN
EXEC @result = sp_OASetPropert y @newmail, 'cc', @cc
IF @result <> 0
BEGIN
PRINT 'Error setting [cc] property'
-- EXEC sp_displayoaerr orinfo @newmail, @result
RETURN
END
END
IF not @Bcc = NULL
BEGIN
EXEC @result = sp_OASetPropert y @newmail, 'Bcc', @Bcc
IF @result <> 0
BEGIN
PRINT 'Error setting [Bcc] property'
-- EXEC sp_displayoaerr orinfo @newmail, @result
RETURN
END
END

--set the non-optional properties
EXEC @result = sp_OASetPropert y @newmail, 'From', @From
EXEC @result = sp_OASetPropert y @newmail, 'To', @To
EXEC @result = sp_OASetPropert y @newmail, 'Subject', @Subject
EXEC @result = sp_OASetPropert y @newmail, 'Body', @Body

-- Send the message...
EXEC @result = sp_OAMethod @newmail, 'Send'
IF @result <> 0
BEGIN
PRINT 'Error sending message'
-- EXEC sp_displayoaerr orinfo @newmail, @result
RETURN
END

-- Destroy the object.
EXEC @result = sp_OADestroy @newmail
IF @result <> 0
BEGIN
PRINT'Error destroying object'
-- EXEC sp_displayoaerr orinfo @newmail, @result
RETURN
END

GO

_______________ _______________ _______________ _
This worked perfectly in testing at our office but when we shipped to
the client it produced the error 'Error creating object'. We sent the
client the script to create the sp_displayoaerr orinfo proc and got the
following error message.

Error creating object-2147221005
OLE Automation Error Information
HRESULT: 0x800401f3
Source: ODSOLE Extended Procedure
Description: Invalid class string
Now this suggested to me that the for some reason we were unable to
reference the CDO library, or it wasn't installed. However they have
Outlook 2000 installed with CDO installed with it. I've had had them
remove and reinstall the CDO library but that hasn't helped.

Other thing I though of was a permission type problem. They are using
NT authentication for there logins into SQL server and are logged on
the server as Administrator who I would assume has all required
permissions.

Any suggestions for either determining the cause of them problems or a
solution?

Thanks in advance.

Bob.

Jul 20 '05 #2
"John Bell" <jb************ @hotmail.com> wrote in message news:<41******* *************** *@news.easynet. co.uk>...
Hi

You may want to look at:
http://www.sqldev.net/xp/xpsmtp.htm

John


The client is using Exchange Server, the dll you have referenced using
SMTP to send the messages - will these work together?

I have made some progress on sorting out the original problem. I
registered two CDO Dll's that documentation lead me to believe were
needed (CDOSYS.DLL and CDO.DLL I think off the top of my head) and the
create object error went away. However I'm now getting an error when
attempting to send the message. I think the problem is with the
installation of CDO, sadly the client has 'lost' the CD used to
install Office 2000 on that server and will have to acquire another -
but can't wait that long for a solution so I will have to look at a
third party solution I suspect.

I have used JMail before but this didn't seem to work when I tried it
here, again this uses SMTP and I'm not sure that Exchange Server will
(by default) provide an SMTP mail server?

Any help very much apprecitated.
Jul 20 '05 #3
Hi

I have only just found this reply! Have you figured out what was
wrong?

If you are using your exchange server to send/receive external emails
then you should have the SMTP connector configured.

John
bu*******@hotma il.com (Robert Hogan) wrote in message news:<eb******* *************** ***@posting.goo gle.com>...
"John Bell" <jb************ @hotmail.com> wrote in message news:<41******* *************** *@news.easynet. co.uk>...
Hi

You may want to look at:
http://www.sqldev.net/xp/xpsmtp.htm

John


The client is using Exchange Server, the dll you have referenced using
SMTP to send the messages - will these work together?

I have made some progress on sorting out the original problem. I
registered two CDO Dll's that documentation lead me to believe were
needed (CDOSYS.DLL and CDO.DLL I think off the top of my head) and the
create object error went away. However I'm now getting an error when
attempting to send the message. I think the problem is with the
installation of CDO, sadly the client has 'lost' the CD used to
install Office 2000 on that server and will have to acquire another -
but can't wait that long for a solution so I will have to look at a
third party solution I suspect.

I have used JMail before but this didn't seem to work when I tried it
here, again this uses SMTP and I'm not sure that Exchange Server will
(by default) provide an SMTP mail server?

Any help very much apprecitated.

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
6404
by: Carlos G Benevides | last post by:
I have a ASP.Net web application that has two assemblies that run under com+. Under Windows 2000 the two assemblies are added to com+ automatically when instantiated from the web site. For this to happen we had to change the context in which asp.net runs from machine to SYSTEM by modifying the machine.config file. Under Windows 2003 no matter how asp.net is set to run as either machine or system. I get the following error: ...
0
7388
by: Pankaj Jain | last post by:
Hi All, I have a class A which is derived from ServicesComponent to participate in automatic transaction with falg Transaction.Required. Class A is exposed to client through remoting on Http channal hosting into IIS. There is a class B which is also available through remoting hosted on IIS on the same URI. B creates new of A inside a function. It succeed and able to create instance of A inside B first time. But it failes in 2nd attempt when...
1
4236
by: hrhoe | last post by:
Hi, I'm trying to create a reusable component with C#. So, I created a user control that uses Microsoft SQLDMO Object Library (SQLDMO). And I could add that UserControl on Toolbox. However, whenever I'm trying to add this user control on the client program's form I'm getting the following error message. ----------------------
0
3118
by: SampathTangudu | last post by:
Hi, We are trying to use the Hash Tables for passing information from one aspx page to another aspx page. We are using the below code. IsolatedStorageFile isoStore = IsolatedStorageFile.GetStore( IsolatedStorageScope.User | IsolatedStorageScope.Assembly |IsolatedStorageScope.Domain , null, null );
3
12993
by: Imran Aziz | last post by:
Hello All, I am getting the following error on our production server, and I dont get the same error on the development box. Unable to cast object of type 'System.Byte' to type 'System.String'. here is the code that I used to create a table and then add columns to it later, later I populate the rows in the table.
0
12064
by: bazzer | last post by:
hey, im trying to access a microsoft access database from an ASP.NET web application in visual basic 2003.NET. i get the following error when i try running it: Server Error in '/CinemaBookingSystem' Application. -------------------------------------------------------------------------------- ERROR General error Unable to open registry key 'Temporary (volatile) Jet DSN for process
2
12839
by: ashishjainism | last post by:
I am unable to install my windows service and the installutil is throwing the following error: Running a transacted installation. Beginning the Install phase of the installation. See the contents of the log file for the d:\practice in .net\mywindowsservice\mywindowsservice\mywindowsservice\bin\practiceservice.exe assembly's progress. The file is located at d:\practice in...
0
789
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted by the software in your host machine. Stack Trace at System.Net.Sockets.NetworkStream.Write(Byte buffer, Int32 offset, Int32
3
14052
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted by the software in your host machine. Stack Trace at System.Net.Sockets.NetworkStream.Write(Byte buffer, Int32 offset, Int32
0
8817
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9322
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9086
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6641
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5964
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4470
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4734
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3170
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2116
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.