Solved

Problem getting CDO to work with T-SQL on Windows 2003

Posted on 2008-06-09
1
430 Views
Last Modified: 2008-08-06
I'm having a hard time getting CDO to work from T-SQL on a Win-2003 64 machine.  

Getting a -2147220960 error on the Send method.

Tried both values 1 and 2 for "sendusing" with the same results.

SMTP service is started on the local machine.

Appreciate any help I can get!  Thanks in advance
set	@MessageObject = 'CDO';

EXEC 	@hr = sp_OACreate 'CDO.Message', @MailID Out;

EXEC 	@hr = sp_OASetProperty @MailID, 'Subject', @Subject ;

EXEC 	@hr = sp_OASetProperty @MailID, 'Sender', @From;

EXEC 	@hr = sp_OASetProperty @MailID, 'From', @From;

EXEC 	@hr = sp_OASetProperty @MailID, 'To', @To;

EXEC 	@hr = sp_OASetProperty @MailID, 'BCC', @BCC;

EXEC 	@hr = sp_OASetProperty @MailID, 'TextBody', @Body;

 

EXEC 	@hr = sp_OASetProperty @MailID, 'Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")', 1;

EXEC 	@hr = sp_OASetProperty @MailID, 'Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")', '127.0.0.1';

EXEC 	@hr = sp_OASetProperty @MailID, 'Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")', 25;

EXEC 	@hr = sp_OAMethod @MailID, 'Configuration.Fields.Update', null
 

EXEC 	@hr = sp_OAMethod @MailID, 'Send';

Open in new window

0
Comment
Question by:quiTech
1 Comment
 
LVL 51

Accepted Solution

by:
tedbilly earned 500 total points
ID: 21756677
Why are you using xp_sendmail on SQL 2005?

http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SQL-Server-2005/Q_22972976.html

CDO requires Exchange or MAPI on the server, CDONTS can work without it and is easier to use.
http://support.microsoft.com/kb/312839
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now