Click here to Skip to main content
16,010,553 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I tried to send mail from sql. i create profile but mail not send.
mail status is failed in sysmail_allitems table

What I have tried:

SQL
GO
sp_CONFIGURE 	'Database Mail XPs', 1 
GO
RECONFIGURE
GO 

USE MSDB
GO

use msdb
go
DECLARE @SUB VARCHAR(100)
SET @SUB = (SELECT 'Employee Report on '+ replace(convert(NVARCHAR, getdate(), 106), ' ', '/')) 
 EXEC sp_send_dbmail @profile_name='test Profile',
@recipients='pandikkl01@gmail.com', @subject=@SUB, 
@body='Attachment File Sent', 
@query= ' SELECT * EMPLOYEEMAS; ,
@query_attachment_filename='test.csv',
@attach_query_result_as_file=1,
@exclude_query_output=1,
@query_result_separator='	',@query_result_width =32767,
@query_result_no_padding=1,
@query_result_header =1
go
Posted
Updated 25-Nov-16 20:02pm

Read the documentation : sp_send_dbmail (Transact-SQL)[^]
 
Share this answer
 
you can also take the help of this link: How To Send Mail Using SQL Server: Part 1[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900