Click here to Skip to main content
15,895,283 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi i am sending email from sqlserver database using html format and sp_send_email:

/*

here i have done database select query with html format

create procedure sp_email (@id int)

.

.

for ex:

/*html design*/

SELECT
TD=tbname1.image,'',
TD=tbname2.ID ,'',
TD=tbname1.Description,'',
FROM tb1 left outer join tb2 on tbname1.ID= tbname2.ID

*/

EXEC msdb.dbo.sp_send_dbmail @recipients = @EMAIL,
@profile_name = 'christ',
@subject = @emailsubject,
@body = @tableHTML,
@body_format = 'HTML'

exec sp_email 2,'chrst@christinfo.com'

After executing that email stored procedure

i am getting output in my mail account like follow.

Image ID Description

0xFFD8FFE00..... 123 Amanatools

here, 0xFFD8FFE000104A4649460 is imagebyte which is in database. i can show as an image in asp.net using imagestream(bitmap concept). but i need to send image instead of bytecode through email stored proecudure. is it possible? How to do that. any help.
Posted

1 solution

you have two options
1 Host the images somewhere, and reference them in the <img src="...">.

2 You could try to encode the image as base64 and reference it directly in an img tag within the email ( <img src="data:image/png;base64[your encoded image here...] ) but i think most email clients correlate this technique with spam. I think you're better off referencing hosted images or simply attaching it to the email.<br mode=" hold=" /><br mode="></img></img>
 
Share this answer
 
Comments
christhuxavier 17-Jan-14 2:03am    
Hi thank you. which option is good?

the first option i understood. i will try.

what is the second option. how to do that? can you give an example?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900