Function to send mail from sql server
1 Answers
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER FUNCTION getmail
(
@from varchar(50),
@to varchar(500),
@subject varchar(100),
@BCC varchar(500),
@FROM_NAME varchar(50),
@MailBody varchar(8000)
)
RETURNS int
AS
BEGIN
declare @rc as int
exec @rc = master.dbo.xp_smtp_sendmail
@FROM= @from,
@FROM_NAME= @FROM_NAME,
@TO= @to,
@BCC= @BCC,
@subject= @Subject,
@message= @MailBody,
@type= N’text/html’,
@server= mailserverip
return @rc
END