469,613 Members | 1,320 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,613 developers. It's quick & easy.

Sending file contents in the body of the email with xp_sendmail

I would like to send the contents of a file using xp_sendmail however
I do not want the file contents to be an attachment.
I have no problem sending the file as an attachement.
Can anybody give me an xp_sendmail example of how to do this.
The results of a query can easily appear in the body of the email but
all my
attempts to include the contents of a file in the body of the email
have not worked.

TIA
Jul 23 '05 #1
1 2758

"Michael McGarrigle" <mj*@barwonwater.vic.gov.au> wrote in message
news:9d**************************@posting.google.c om...
I would like to send the contents of a file using xp_sendmail however
I do not want the file contents to be an attachment.
I have no problem sending the file as an attachement.
Can anybody give me an xp_sendmail example of how to do this.
The results of a query can easily appear in the body of the email but
all my
attempts to include the contents of a file in the body of the email
have not worked.

TIA


Rather than use xp_sendmail, you could check out xp_smtp_sendmail:

http://www.sqldev.net/xp/xpsmtp.htm

It has a @messagefile parameter which looks like it may do what you want.
Otherwise, you can use xp_cmdshell to read the file into a table, then query
the table to get the message body:

create table ##t (col1 varchar(1000))
insert into ##t exec master..xp_cmdshell 'type c:\myfile.txt'
exec master..xp_sendmail
@recipients = 's******@somewhere.com',
@query = 'select col1 from ##t'
...

This is quite similar to example E for xp_sendmail in Books Online.

Simon
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Anuradha | last post: by
14 posts views Thread by John | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.