[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 427
  • Last Modified:

DB Mail with HTML code

Can someone please help me get the following to work?  Currently, the email has a blank for the body content!!

Thanks!

DECLARE @message NVARCHAR(MAX)
 
 
SET @message = N'<html><body><iframe src ="C:\test.txtl" width="500" height="300"></iframe></body></html>'
 
 
EXEC msdb..sp_send_dbmail
@profile_name=N'Database Mail',
@recipients=N'me@domain.ca',
@subject=N'Email Test'',
@body = @message,
@body_format ='HTML';

Open in new window

0
TheGoofyOne
Asked:
TheGoofyOne
  • 4
  • 3
1 Solution
 
BrandonGalderisiCommented:
That would require that each local machine viewing the mail, IF it worked, to have "c:\temp.txt1" locally.
0
 
TheGoofyOneAuthor Commented:

Hi Brandon,

What I'm trying to do is basically list the output of a text file in the body of my email. Do you have another way around this?

Thanks,
Mary
0
 
BrandonGalderisiCommented:
Is the text file on the DB Server?
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
TheGoofyOneAuthor Commented:
Yes it is
0
 
BrandonGalderisiCommented:
You want to use the bulk insert:

http://msdn.microsoft.com/en-us/library/ms188365.aspx

Maybe something like this...
DECLARE @message NVARCHAR(MAX)
 
create table #Data(i int identity, d nvarchar(max))
 
BULK INSERT #Data
   FROM 'C:\test.txtl'
   WITH
     (
        ROWTERMINATOR = '\n',
      )
 
select @message = isnull(@message + N'
',N'') + d from #Data
 
drop table #data
 
EXEC msdb..sp_send_dbmail
@profile_name=N'Database Mail',
@recipients=N'me@domain.ca',
@subject=N'Email Test'',
@body = @message;

Open in new window

0
 
BrandonGalderisiCommented:
Is this REALLY a B answer.  Did it not do what you desired?
0
 
TheGoofyOneAuthor Commented:

BrandonGalderisi:

The idea you gave was great, unfortunately, when I ran it I received the following error:




Bulk load: DataFileType was incorrectly specified as char. DataFileType will be assumed to be widechar because the data file has a Unicode signature.
Bulk load: DataFileType was incorrectly specified as char. DataFileType will be assumed to be widechar because the data file has a Unicode signature.
Msg 4832, Level 16, State 1, Line 6
Bulk load: An unexpected end of file was encountered in the data file.
Msg 7399, Level 16, State 1, Line 6
The OLE DB provider "BULK" for linked server "(null)" reported an error. The provider did not give any information about the error.
Msg 7330, Level 16, State 2, Line 6
Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".

Open in new window

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now