Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 sp_send_dbmail with inline pictures

Author  Topic 

stephenbaer
Yak Posting Veteran

71 Posts

Posted - 2011-06-04 : 17:37:05
Hi, I'm trying to send an email with pictures as inline attachments, i.e. MHTML. (actually, I'm trying to send an email with a green checkmark gif for a bit value of 'true'(-1), and a a red X gif for a bit value of 'false'(0), but I'll settle for just figuring out how to embed the base 64 gifs as a start). Anybody have and pointers? The folowing doesn't work at all (even the char(10)s and char(13)s are ignored
I started with an example from the rfc for multipart Mime, with my own gifs:

DECLARE @tableHTML NVARCHAR(MAX) ;
SET @tableHTML = N'Mime-Version: 1.0' + CHAR(13)+ CHAR(10) +
N'Content-Type: multipart/related; boundary="boundary";' + char(13) +
N' type="text/html" ' +
N' --boundary' +
N' Content-Type: text/html; charset="US-ASCII"' +
N' ... text of the HTML document, which might contain a URI' +
N' referencing a resource in another body part, for example' +
N' through a statement such as:' +
N' <IMG SRC="cid:check16" ALT="Yes">' +
N' <IMG SRC="cid:x16" ALT="No">' +
N' --boundary' +
N' Content-Location: CID:somethingelse ; this header is disregarded' +
N' Content-ID: <check16>' +
N' Content-Type: IMAGE/GIF' +
N' Content-Transfer-Encoding: BASE64,R0lGODlhEAAQAPcAAAAAABG3JBK2Jhe9Khi+KyjOOyrQPS3RPj7iT////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAP8ALAAAAAAQABAAAAhiAP8JHIigIIKBCAkaXJhQIIIDBSJKLGAgIYKJGCMShJhxYgCHHSUm0FgwZIGREQOU7Igy5UqMCVoWUHkRpsyZ/y7GjLgTI8iTMW8WEDBQZM+JCUVm/JhwQEYCDREGmMoUYUAAOw==' +
N' --boundary-
N' --boundary' +
N' Content-Location: CID:something@else ; this header is disregarded' +
N' Content-ID: <x16>' +
N' Content-Type: IMAGE/GIF' +
N' Content-Transfer-Encoding: BASE64,R0lGODlhEAAQAPcAAAAAAMcKAMYMAM0QAN4hEOAjEuEjFfI0Jv///wAAAAAAAAAAAAAAAAAAAA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YcGJGAkghEgAAQKJHiMGcAgypMePEf9dLHlyYoCVLDG+PDDxZEiJM2O2FKmypM+UPTNiFDBQKMaERiMeTDgg44CGCANIHZkwIAA7' +
N' --boundary-'

EXEC msdb.dbo.sp_send_dbmail
@recipients= 'sbaer@mydomain.org',
@subject = 'pretty pictures',
@body = @tableHTML,
@body_format = 'HTML' ;


----------------
-Stephen

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-06-05 : 03:51:52
didnt get what error you're facing. can you explain?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

stephenbaer
Yak Posting Veteran

71 Posts

Posted - 2011-06-05 : 18:01:07
Oh, it parses/compiles just fine, but it sends the email that has all the text in it, rather than hiding the mime stuff like the boundaries.

----------------
-Stephen
Go to Top of Page
   

- Advertisement -