SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Need help on HTML formatted email from Stored Procedure


Need help on HTML formatted email from Stored Procedure

Author
Message
jaype-365633
jaype-365633
SSC Rookie
SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)

Group: General Forum Members
Points: 43 Visits: 111
Hi, i had created a trigger to send email whenever the new data is inserted or updated which sends the email in one line, i need to send the email in HTML format from stored Procedure, please help.
Attached the image how the mail to be sent.
Attachments
SP.JPG (81 views, 21.00 KB)
LutzM
LutzM
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10391 Visits: 13559
Please provide table def and sample data as described in the first link in my signature.
It will help us to test our solutions.



Lutz
A pessimist is an optimist with experience.

How to get fast answers to your question
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
jaype-365633
jaype-365633
SSC Rookie
SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)

Group: General Forum Members
Points: 43 Visits: 111
Hi Lutz, i am not getting the place to post on your first link, in trigger i have used
/****** Object: Trigger [dbo].[New_Author] Script Date: 04/28/2010 16:01:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[New_Author] ON [dbo].[CLINICIANS] AFTER INSERT, UPDATE AS
DECLARE @SOURCEID VARCHAR(50)
DECLARE @DATAID varchar(50)
DECLARE @DEPTID varchar(50)
DECLARE @AID varchar(50)
DECLARE @ARDESC varchar(50)
DECLARE @HID varchar(50)
SET @SOURCEID = (select sourceid from inserted)
SET @DATAID = (SELECT TRUSTID FROM inserted)
SET @AID = (SELECT AUTHORID FROM inserted)
SET @DEPTID = (SELECT DEPTID FROM inserted)
SET @AD = (SELECT AUTHORDESC FROM inserted)
SET @HID = (SELECT HOSPITALID FROM inserted)
IF (UPDATE (AUTHORID))
BEGIN
DECLARE @msg varchar(500)
SET @msg = 'NEW EMP "' + @aid + '" RECEIVED IN THE "' +@SOURCEID+'.' + @DATAID + '" AND DESCRIPTION IS "'
+ @ARDESC + '" AND THE DEPARTMENT IS "' + @DEPTID + '"'
EXEC msdb.dbo.sp_send_dbmail
@recipients=N'jaiprakash23@hotmail.com',
@copy_recipients='jaiprakash23@hotmail.com',
@body= @MSG,
@subject = 'New EMP Received',
@profile_name = 'Jaype'
END

getting the mail in one line as
NEW EMP "2008" RECEIVED IN THE "IT" AND THE DESCRIPTION IS "Information Technolog" AND THE DEPARTMENT IS "Sysadmin"
shen-dest
shen-dest
Old Hand
Old Hand (340 reputation)Old Hand (340 reputation)Old Hand (340 reputation)Old Hand (340 reputation)Old Hand (340 reputation)Old Hand (340 reputation)Old Hand (340 reputation)Old Hand (340 reputation)

Group: General Forum Members
Points: 340 Visits: 409
Hi,
you can use HTML tags to format your @MSG variable.We send html-formatted mails for other purposes.

Regards,
MShenel
LutzM
LutzM
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10391 Visits: 13559
Your trigger code won't work as soon as there is more than 1 row affected.
You need to rethink your process to decide how to deal with that.



Lutz
A pessimist is an optimist with experience.

How to get fast answers to your question
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search