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 Development (2000)
 send mail....

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-04-08 : 07:33:07
nitin writes "hi sir i am using the procedure on your site
http://www.sqlteam.com/item.asp?ItemID=5003
... i am able to do run them successufully but didnt get a mail... i dont know what wrong i am doing..would you please guide me...thanks a lot...


exec pubs.dbo.sp_SMTPMail @SenderName='me', @SenderAddress='nitinsharma@cvdpl.com',
@RecipientName = 'Someone', @RecipientAddress = 'nitinsharma@cvdpl.com',
@Subject='SQL Test', @body='Hello, this is a test email from SQL Server',
@mailserver='10.0.35.12'

this command i am giving to execute the following procedure...

Create Procedure sp_SMTPMail

@SenderName varchar(100),
@SenderAddress varchar(100),
@RecipientName varchar(100),
@RecipientAddress varchar(100),
@Subject varchar(200),
@Body varchar(8000),
@MailServer varchar(100) = '10.0.35.12'

AS

SET nocount on

declare @oMail int --Object reference
declare @resultcode int

EXEC @resultcode = sp_OACreate 'SMTPsvg.Mailer', @oMail OUT

if @resultcode = 0
BEGIN
EXEC @resultcode = sp_OASetProperty @oMail, 'RemoteHost', @mailserver
EXEC @resultcode = sp_OASetProperty @oMail, 'FromName', @SenderName
EXEC @resultcode = sp_OASetProperty @oMail, 'fromaddress', @SenderAddress

EXEC @resultcode = sp_OAMethod @oMail, 'AddRecipient', NULL, @RecipientName,

@RecipientAddress

EXEC @resultcode = sp_OASetProperty @oMail, 'Subject', @Subject
EXEC @resultcode = sp_OASetProperty @oMail, 'BodyText', @Body


EXEC @resultcode = sp_OAMethod @oMail, 'SendMail', NULL

EXEC sp_OADestroy @oMail
END


SET nocount off

GO"

AndyB13
Aged Yak Warrior

583 Posts

Posted - 2003-04-08 : 11:13:38
Hi
Have you obtained the following - quote from SQLTeam Item 5003
quote:
sp_SMTPMail is a stored procedure that calls the ASP Mail COM object from www.serverobjects.com to send an email.


Alternatively you could use CDONTS/CDO if you have IIS installed

[url]http://support.microsoft.com/view/tn.asp?kb=312839[/url]

HTH

Andy

Go to Top of Page
   

- Advertisement -