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)
 xp_sendmail

Author  Topic 

nishithrn
Yak Posting Veteran

58 Posts

Posted - 2004-05-19 : 12:50:28
Hello All,

I am configuring xp_sendmail, wherein I want to pass a variable to @messages paramater. Can any body tell me how to do it..???

Regards

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-05-19 : 13:01:15
It's the same way as you would any other stored procedure:

DECLARE @test VARCHAR(8000)

SET @test = 'This is a test'

EXEC master.dbo.xp_sendmail @recipients = 'test@company.com', @subject = 'test', @message = @test

Tara
Go to Top of Page

nishithrn
Yak Posting Veteran

58 Posts

Posted - 2004-05-20 : 07:08:55
Hi Tara,

Tx a lot for your reply. But one more thing. What if I want the use a variable in the @message paramter alongwith some text.

For eg.

DECLARE @test VARCHAR(8000)
SET @test = 'This is a test'
EXEC master.dbo.xp_sendmail @recipients = 'test@company.com', @subject = 'test', @message = 'The Message is' + @test.

How do I do it..?? Ofcourse, the example above will definately give an error.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-05-20 : 12:08:45
DECLARE @Message VARCHAR(7000)
DECLARE @test VARCHAR(8000)

SET @test = 'This is a test'
SET @Message = 'The Message is ' + @test

EXEC master.dbo.xp_sendmail @recipients = 'test@company.com', @subject = 'test', @message = @Message

Tara
Go to Top of Page

smousumi
Starting Member

19 Posts

Posted - 2004-05-28 : 02:38:37
Hii all,
Even i am using xp_sendmail to automatic send mail from sql server,
But getting error......like below...

xp_sendmail: failed with mail error 0x80040111

I am using like...

DECLARE @test VARCHAR(8000)
SET @test = 'This is a test mail'
EXEC master.dbo.xp_sendmail @recipients = 'sahoo@satyam.com', @subject = 'Testing', @message = @test

pls help

mousumi
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-05-28 : 12:21:26
Have you rebooted? That typically fixes SQL Mail if it was working before. Also Outlook 2000 fixes a few problems if you are running Outlook 1997.

Search the knowledge base for your error:

http://support.microsoft.com/

Tara
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-05-28 : 13:46:56
Try running xp_stopmail and xp_startmail first.

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page
   

- Advertisement -