Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send email from SQL server

Status
Not open for further replies.

Nikrek

Programmer
Joined
Jan 15, 2002
Messages
2
Location
US
Hi all. I need help sending emails from SQL server.
Normally I would use xp_sendmail, however at this time,
I need to change sender's email (name). Can't do it with xp_sendmail. Also I tried to use CDONTS.Newmail in
ActiveScript task of DTS package. It does recognize
the Newmail object, but complains over Send method.
Send Mail task of DTS also is no good, since I need
to build an email body based on select statement, and I
don't see any way to use Send Mail with a dynamic content.

Please help,
Thanks in advance
 
Use Dinamic SQL to create the xp_sendmail statement:
Exemplo:
declare @Message varchar(255), @Query varchar (255)
SET @Query = 'Query to includ with the Body of the E-mail'
SET @Message = 'Boddy of the Message or Variable with the Concatenated Text Here'
EXEC master..xp_sendmail @recipients ='Email Address', @message = @Message, @Query =@Query, @dbuse = 'Your Database Name Here'

I hope it helps, for more info read the BOL article "xp_sendmail" AL Almeida
NT/DB Admin
"May all those that come behind us, find us faithfull"
 
Thanks Al,
but again, the issue is that I can't change sender's
address (From part) using xp_sendmail since it's tight
to existing profile.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top