Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 SQL Mail

Author  Topic 

RM
Yak Posting Veteran

65 Posts

Posted - 2005-08-31 : 05:27:20
Hi,

I'm facing problem in sending mail through SQL. When I send a mail through XP_sendMail it show Mail Sent. But the mail is not received by the recepient. Job status is also not getting mailed. The test "send mails" are successful, but the mails are not received by the recepient. I'm able to send the mails through outlook. Need your help here.

Thanks

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-31 : 05:34:19
Try this



CREATE PROCEDURE SendMail(
@From varchar(255),
@To varchar(255),
@Message varchar(8000),
@Subject varchar(255))
AS

DECLARE @CDO int, @OLEResult int, @Out int

EXECUTE @OLEResult = sp_OACreate 'CDONTS.NewMail', @CDO OUT
IF @OLEResult <> 0 PRINT 'CDONTS.NewMail'


EXECUTE @OLEResult = sp_OASetProperty @CDO, 'BodyFormat', 0
EXECUTE @OLEResult = sp_OASetProperty @CDO, 'MailFormat', 0


execute @OLEResult = sp_OAMethod @CDO, 'Send', Null, @From, @To, @Subject, @Message, 1
IF @OLEResult <> 0 PRINT 'Send'


EXECUTE @OLEResult = sp_OADestroy @CDO

return @OLEResult


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

RM
Yak Posting Veteran

65 Posts

Posted - 2005-08-31 : 05:43:28
Hi madhivanan,

Thanks for replying.

So, do you want me to execute this sproc and send the mails through it? Will executing this proc solve the problem of sending job status through mails?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-31 : 05:45:53
Test it yourself

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

RM
Yak Posting Veteran

65 Posts

Posted - 2005-08-31 : 06:11:51
This proc works fine but my problem still persists. I think I'm not able to explain it properly. Let me put it again. Thorugh EM I go to Jobs. I check for properties. I go to notifications tab, I choose Email Operator , click on ... button, send a test mail. I get message Mail sent successfully. But the mail is not received by the recepient.
Go to Top of Page
   

- Advertisement -