November 7, 2013 at 2:35 am
Hi
I want to send an image in mail body from database mail
Declare @html_docy nvarchar(max) =
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div id="Maincontainer">
<div id="EmailContent">
<div>
<img src="logo.png" width="235" height="70" border="0" alt=""/>
<hr />
</div>
<div style="padding-top: 20px">
<span style="font-size: 10pt; margin-bottom: 0.0001pt; font-family: arial,helvetica,sans-serif;"></body>'
EXEC msdb.dbo.sp_send_dbmail
@profile_name='my_profile',
@file_attachments = 'c:\logo.png',
@recipients='xyz@gmail.com',
@subject = 'Tests',
@body = @html_docy,
@body_format = 'HTML'
here i could not see image in mail body..in attachment i can see??
can any one help me with this??
please find attachment
November 7, 2013 at 6:36 am
it's not obvious, but if you look at the html source of some of your own email, the trick is referencing the content id(cid) of the attachment(s) that was included; by using the cid:, you'll get the image inline, butdepending on the email program (i.e. Thunderbird), the image may still be prevented from showing at all, without an explicit user selection.
<img src="cid:logo.png" width="235" height="70" border="0" alt=""/>
Lowell
January 16, 2014 at 8:36 pm
$t@r (11/7/2013)
HiI want to send an
edited image[/url] in mail body from database mailhere i could not
see image[/url] in mail body..in attachment i can see??can any one help me with this??
please find attachment
:-)Attach required images using @file_attachments separate them using ; an then use their names (only file name with extension) in @body.
more at:
or may be you can have a look at:
http://www.sqlservercentral.com/Forums/Topic1292947-391-1.aspx
January 17, 2014 at 6:06 am
actually, using the content id (cid:) is the right way.
by leaving it out, you are just taking advantage of some email clients smart features of filling in missing tags, the same way all clients will automatically insert a missing/implied </td> tag.
so doing it that way , you'll eventually get someone who says they don't see the images, and it'll be because their spcific email client didn't re-vamp the html to fix the mistake.
in this post here, i provided a complete coded example for sp_send_dbmail
http://www.sqlservercentral.com/Forums/FindPost941817.aspx
Lowell
January 17, 2014 at 9:19 pm
Lowell (1/17/2014)
actually, using the content id (cid:) is the right way.by leaving it out, you are just taking advantage of some email clients smart features of filling in missing tags, the same way all clients will automatically insert a missing/implied </td> tag.
so doing it that way , you'll eventually get someone who says they don't see the images, and it'll be because their spcific email client didn't re-vamp the html to fix the mistake.
in this post here, i provided a complete coded example for sp_send_dbmail
THAT would make a great "SQL Spackle" article, Lowell. You should write it up and submit it.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply