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 2005 Forums
 Transact-SQL (2005)
 How to Send Mail every Friday From SQLSERVER 2005

Author  Topic 

nadavala.ravindra
Starting Member

3 Posts

Posted - 2008-08-18 : 01:24:20
hi,
i am new to SQL Server.i need to send mail as HTML every friday auto matically with Content from Table Data.Right now i am sending mail through ASP.net code but it needs application runs continously.


Please ignore grammer mistakes


Thanks in Advance.
Ravindra.N

dexter.knudson
Constraint Violating Yak Guru

260 Posts

Posted - 2008-08-18 : 01:37:42
See xp_sendmail & SSMS -> SQL Server Agent -> Jobs
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-18 : 01:38:36
Use sp_send_dbmail. For sending it every friday create a job on sql agent to call sp_send_dbmail and schedule it to process on each friday. you can use query option in sendmail to sedn query results as mail.

http://www.kodyaz.com/articles/sql2005-database-mail.aspx
Go to Top of Page

nadavala.ravindra
Starting Member

3 Posts

Posted - 2008-08-18 : 02:00:00
hi,
Thanks for Reply. i will go through that..get back you

Ravindra.N
Go to Top of Page

nadavala.ravindra
Starting Member

3 Posts

Posted - 2008-08-19 : 04:45:16
hi,
i wrote proc below to send mail from SQL Server
which will call by SQL agent

ALTER PROCEDURE Usp_TestSummaryMail AS
declare @MailText varchar(8000)
begin
declare @profile_name varchar(max)
declare @recipients varchar(max)
declare @body_format nvarchar(255)
declare @body nvarchar(max)
declare @importance varchar(10)
declare @sqlstr varchar(max)
set @MailText='Body Text'
set @sqlstr ='
EXEC msdb.dbo.sp_send_dbmail
@profile_name = ''ProfileName'',
@recipients = ''mailid'',
@body_format = ''HTML'',
@subject = ''Subject'',
@body='''+@MailText+''',
@importance = ''High'';'

exec(@sqlstr)
Return
End


this procedure is executing and giving output as 'MailQueued'
but mail is not going.i created account and profile.

i am not getting where is problem.

Thanks in Advance
Ravindra.N
Go to Top of Page
   

- Advertisement -