|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Wednesday, May 08, 2013 1:25 PM
Points: 38,
Visits: 90
|
|
Hello all and thank you in advance for your time and expertise.
I am sending out customer statements in email using dbmail on sql 2008. I'd like to put our corporate logo on top of the email, but I'm having difficulty doing it. I found an article on the web that showed me how to put html tags into documents (I'm not a programmer, in case you can't tell ) and I have this line in my sql statement: <img src="\\waccounting\images\logo.gif" width="400" height="100" border="0"/>
When the email goes out, the image is blank on the email. Has anyone been able to put an image into their emails that get sent out by dbmail? If so, how?
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Monday, May 13, 2013 2:44 PM
Points: 18,
Visits: 292
|
|
I don't have an answer as I've never done this, but you're referring to a local server as the image storage location.
Is this email only going to an intranet where all recipients would have access to this server & file?
Could it be an issue of needing to actually attach the image to the email?
Jim
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Friday, May 10, 2013 3:16 PM
Points: 263,
Visits: 269
|
|
Keep in mind that most email clients do not automatically load images in emails for privacy reasons. I expect that isn't the issue, but I wanted to mention it.
The problem is probably your file URI, which is incorrect.
Try this:
<img src="file://waccounting/images/logo.gif" width="400" height="100" border="0"/>
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Wednesday, May 08, 2013 1:25 PM
Points: 38,
Visits: 90
|
|
| This is going externally - it's going out to our customers. I want to put our logo at the top of the email. Right now, it's blank.
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Wednesday, May 08, 2013 1:25 PM
Points: 38,
Visits: 90
|
|
Robert Cary (6/22/2010)
Keep in mind that most email clients do not automatically load images in emails for privacy reasons. I expect that isn't the issue, but I wanted to mention it. The problem is probably your file URI, which is incorrect. Try this: <img src="file://waccounting/images/logo.gif" width="400" height="100" border="0"/>
Robert, Thanks for the input, but it still didn't work. You are right - outlook did block the image. But when I allowed the image to come through, it still showed blank.
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Yesterday @ 1:11 PM
Points: 11,605,
Visits: 27,645
|
|
the secret is to use cid:attachedimage.gif for the source file.
here's a setup and working example: I'm attaching the results of a query, and i copied the SQl server logo to my C:\ drive of my sql server.
declare @body1 varchar(4000) set @body1 = '<head> <title> Embedded Logo Example</title> <meta name="Generator" content="EditPlus"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> </head> <body> <table><tr><td valign="top" align="left">MyHeader</td></tr> <tr><td valign="top" align="left"><img src="cid:sqlservercentral_logo.gif" width="235" height="70" border="0" alt=""></td></tr> </table> </body>' EXEC msdb.dbo.sp_send_dbmail @profile_name='MyDefault EmailProfile', @recipients='lowell@somedomain.net', @subject = 'SQl 2008 email test', @body = @body1, @body_format = 'HTML', @query = 'SELECT top 3 * from sysobjects where xtype=''U''', @query_result_header = 0, @exclude_query_output = 1, @append_query_error = 1, @attach_query_result_as_file = 1, @query_attachment_filename = 'results.txt', @query_result_no_padding = 1, @file_attachments = 'C:\sqlservercentral_logo.gif'
Lowell
--There is no spoon, and there's no default ORDER BY in sql server either. Actually, Common Sense is so rare, it should be considered a Superpower. --my son
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Wednesday, May 08, 2013 1:25 PM
Points: 38,
Visits: 90
|
|
Lowell (6/23/2010)
the secret is to use cid:attachedimage.gif for the source file. here's a setup and working example: I'm attaching the results of a query, and i copied the SQl server logo to my C:\ drive of my sql server. declare @body1 varchar(4000) set @body1 = '<head> <title> Embedded Logo Example</title> <meta name="Generator" content="EditPlus"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> </head> <body> <table><tr><td valign="top" align="left">MyHeader</td></tr> <tr><td valign="top" align="left"><img src="cid:sqlservercentral_logo.gif" width="235" height="70" border="0" alt=""></td></tr> </table> </body>' EXEC msdb.dbo.sp_send_dbmail @profile_name='MyDefault EmailProfile', @recipients='lowell@somedomain.net', @subject = 'SQl 2008 email test', @body = @body1, @body_format = 'HTML', @query = 'SELECT top 3 * from sysobjects where xtype=''U''', @query_result_header = 0, @exclude_query_output = 1, @append_query_error = 1, @attach_query_result_as_file = 1, @query_attachment_filename = 'results.txt', @query_result_no_padding = 1, @file_attachments = 'C:\sqlservercentral_logo.gif'
That was it. My other problem was the @file_attachments parameter - I didn't have that. Thank you very much!
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 5:29 PM
Points: 6,367,
Visits: 8,226
|
|
Cool, I was hoping that there was a solution for this, it just sounded like a reasonable thing to do.
Good job Lowell!
(Now if only one could bookmark a forum post on this site...)
Wayne Microsoft Certified Master: SQL Server 2008 If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it! Links: For better assistance in answering your questions, How to ask a question, Performance Problems, Common date/time routines, CROSS-TABS and PIVOT tables Part 1 & Part 2, Using APPLY Part 1 & Part 2, Splitting Delimited Strings
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: 2 days ago @ 12:14 PM
Points: 125,
Visits: 498
|
|
Thanks to forum (again) , i have something new to offer to my client...
Cheers, Ankur
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Sunday, May 05, 2013 9:29 PM
Points: 116,
Visits: 554
|
|
I will have an upcoming use of printing a logo in my emails out to clients. I stumbled onto this forum looking for the syntax to use sp_send_dbmail without setting up the Database Mail client (like what credentials do I use to pass to the SMTP server?). This is the cart before the horse, but you guys are great and I won't have any problem with how my email will appear. Another satisfied customer of SSC!!
|
|
|
|