March 15, 2009 at 10:16 am
Hi,
i want to show Images in my mails, i am using sp_send_dbMail in HTML mode. is there any way that i can show Images in my mails.
March 15, 2009 at 10:25 am
yes you can show images in your HTML emails. Do you want to post the code you have so far. Is the SP failing to execute or are you just getting the mail without the image?
edited to add test code i used a while back which worked fine
DECLARE @HTML NVARCHAR(MAX) ;
SET @HTML =
' '+
' ' +
' ' +
' ' +
' ' +
'
' +
'
' +
' ' +
' ' +
' ' + ' ' +
CAST ( ( select emailaddy from EmailTest where id = @count)
AS NVARCHAR(MAX));
EXEC msdb.dbo.sp_send_dbmail @recipients=@rec,
@subject = 'Test HTML Email from SQL',
@body = @HTML,
@body_format = 'HTML' ;
March 15, 2009 at 10:32 am
rar!! can someone tell me how to post HTML code without it removing all the tags...please? 🙂
March 15, 2009 at 11:18 am
Hi,
Thanks for the Reply, here exactly mode code is,
my question is that in my Query lets say i have as Follow:
CAST(( Select td=[Name],'' from abc Xml path('tr') ......
lets say here i also have a column name Image so i want to show indicator based on the condition where i can show status kind of thing....lets say above Query Result would be like:
XYZ RED
ABC YELLOW
kind of, is this possible,
Thanks
Parth
March 15, 2009 at 2:41 pm
im not 100% sure if you can do that kind of thing in HTML code or not. From what i can tell you are trying to return some kind of traffic light indicator based on what the query result is?
If i were you i would declare a variable, and then run a standard tsql query to determine whether it should be red/yellow/green, then use a case/if statement to produce your email, ie...
declare @ind varchar(10)
set @ind = (select case ColumnName when xxx then 'Green' when yyy then 'Yellow' else Red End)
if @ind = 'Green'
-- put email code here and set the font/background to green, however you want it to show
if @ind = 'Yellow'
-- put email code here and set the font/background to yellow
if @ind = 'Red'
-- put email code here and set the font/background to red
would that do the job?
March 16, 2009 at 5:46 am
i have already tried it and it is working fine but my Que. is i want to show images like
on condition basis like below:
td=case when some thing then <img ....... else something end ,'' ,
this kind of thing , and i have tried this also but with no luch rather it is taking this thing as Text and shows me the Text in case statement.
Thanks anyways
Parth
March 16, 2009 at 5:51 am
I dont believe you can do a case statement within HTML. If you cant implement the solution i mentioned in my last post it might be possible to end your HTML string, do you Case statement as part of the tsql command and then continue your HTML tags afterwards. This will work the same way as inserting a value from a sql query into your HTML code. Unfortunately i still havent worked out how to post HTML so i cant post any example code right now.
March 16, 2009 at 6:03 am
SEND ME MAIL ON parth83.rawal@gmail.com,
though i am already having html code but issue only is not able to put image in my HTML.
March 16, 2009 at 6:45 am
parth83.rawal (3/16/2009)
SEND ME MAIL ON parth83.rawal@gmail.com,though i am already having html code but issue only is not able to put image in my HTML.
Just emailed you, let me know if you dont get it
May 28, 2009 at 1:40 pm
Animal, I have the same issue, can you email me the solution you posted at jonesbilly0@gmail.com. Thanks in advance.
May 28, 2009 at 11:18 pm
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply