Thread: Image datatype and HTML Emails
10-15-09, 12:23 #1Registered User
- Join Date
- Oct 2009
Unanswered: Image datatype and HTML Emails
I am trying to embed a photograph (Held as image in SQL server 2005) into an email. However, the resultant email does not display the photograph.
As anyone tried to do this before ?
The sample code I'm using is below ;
DECLARE @Contact_Email NVARCHAR(100),
SET @Contact_Email = 'firstname.lastname@example.org'
SET @applicantPicture = CONVERT(VARBINARY(MAX), (select photograph from person where personid = 7008))
SET @CctEmailSubject = 'TEST OF PHOTO EMAIL'
SET @emailbody = 'Some Text abcdefghijklmnopqrstuvwxyz<br/>'
+ '<div align="left"><img src="[Applicant.Picture]" /></div>'
IF @ApplicantPicture is not null
Set @EmailBody = Replace@EmailBody, '[Applicant.Picture]',@applicantpicture)
EXEC dbo.SEND_MAIL @recipients = @Contact_Email,
@subject = @CctEmailSubject, @body = @EmailBody,
@body_format = 'HTML' ;
The SEND_MAIL procedure simply uses;
EXEC @Rslt = msdb.dbo.sp_send_dbmail @profile_name = @profile_name,
@recipients = @recipients,
@copy_recipients = @copy_recipients,
@blind_copy_recipients = @blind_copy_recipients,
@subject = @subject, @body = @body, @body_format = @body_format,
@importance = @importance, @sensitivity = @sensitivity,
@file_attachments = @file_attachments
Many Thanks, Andyb_Reg
10-15-09, 17:23 #2Annie's Dog Walker
Provided Answers: 6
- Join Date
- Nov 2004
- on the wrong server
sql server is not file cabinet. do not use it as such. I think the pics have to be available via a publicly accessible URL on a web servers file system. you can store the url in the database and send it out as part of your email.If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry. Earnest Hemingway, A Farewell To Arms.