quiTech
asked on
Problem getting CDO to work with T-SQL on Windows 2003
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
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';
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.