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.
Author |
Topic |
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2008-02-28 : 15:09:02
|
Thanks to jhocutt it's working but I don't like how the output displays the info in the email. Is there a way for me to format it: This is how it's coming out.Is there a way to format Requestor Requested Shipped Due ------------------------------------------------------------------------------ ----------------------------------------------------------------------- ----------------------------------------------------------------------- ----------------------------------- ----------------------------------------------------------------------- ---- ------------------------------ ------------------------------ ------------------------------ Approaching the Corporate Heart pc@yahoo.com 02/07/2008 02/07/2008 02/06/2008 PASSION FOR CUSTOMERS 3 copies pc@yahoo.com 02/07/2008 02/07/2008 02/06/2008 PASSION FOR CUSTOMERS 3 copies Here's the code:declare @requestoremail varchar(75), @myquery VARCHAR(4000)Declare GetEmails cursor for select requestors.requestoremail --selecting person to send email toofrom spdtlibrary.dbo.libraryrequest as libraryrequestjoin spdtlibrary.dbo.requestors as requestors on requestors.requestorid=libraryrequest.requestoridjoin spdtlibrary.dbo.Titles as titles on Titles.Titleid = Libraryrequest.titleidWHERE returndate is null and duedate < DATEADD(day, DATEDIFF(day, 0, CURRENT_TIMESTAMP) - 7, 0) OPEN GetEmailsFETCH NEXT FROM GetEmails INTO @requestoremailWHILE @@FETCH_STATUS >= 0BEGINPrint @requestoremail set @myquery = 'select Titles.Title), requestors.requestoremail as Requestor, convert(varchar,libraryrequest.requestdate,101)as Requested,convert(varchar,libraryrequest.shipdate,101)as Shipped,convert(varchar,libraryrequest.duedate,101)as Duefrom spdtlibrary.dbo.libraryrequest as libraryrequestjoin spdtlibrary.dbo.requestors as requestors on requestors.requestorid=libraryrequest.requestoridjoin spdtlibrary.dbo.Titles as titles on Titles.Titleid = Libraryrequest.titleidWHERE returndate is null and duedate < DATEADD(day, DATEDIFF(day, 0, CURRENT_TIMESTAMP) - 7, 0) and requestoremail= ''' + @requestoremail + ''''execute master..xp_sendmail @recipients = @requestoremail, @subject = 'Over Due Resource Library Item', @message = 'Our records indicate that the item you recently borrowed from ETDTs Resource Library has not yet been returned. Please FEDEX it to the address below as soon as possible so that it is available for other employees to utilize. Please place a post-it note on the item to identify yourself as the requestor. (Please check with your manager about FEDEX mailing procedures in your office.) Thank you.SSARegional Training Facility444 North 3rd St.4th FloorPhiladelphia, PA 19123Attention: Tonia Porter', @query = @myqueryFETCH NEXT FROM GetEmails INTO @requestoremail;ENDclose GetEmailsdeallocate GetEmails |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-02-28 : 15:45:28
|
You can't really format the email body with xp_sendmail. What I do instead is attach my data that has been formatted in the query.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2008-02-29 : 15:06:00
|
Bummer...thanks anyway. |
 |
|
|
|
|
|
|