Solved

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

Posted on 2008-06-09
1
433 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:
Ted Bouskill 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 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