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
 Transact-SQL (2005)
 Sql Mail String

Author  Topic 

kenlok
Starting Member

16 Posts

Posted - 2009-11-05 : 06:46:20
Dear Sir,

I would like to use SQL Mail to mail below table with mail.

How can I do it in function?

Thanks


SQL Mail
------------------------------------
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'Alert',
@recipients = Email,
@body = 'Use new feature of Database mail. No MAPI client needed',
@subject = 'New Feature of Database Mail'

Table 1
------------------------------------
Order_No StyleNo Subject SalesTeamId FrValue ToValue PointId CreateDateTime
20001B TEST Color 12 (90) (100)
20001B TEST Quantity 12 145 155
20002B TEST Quantity 13 147 159

Table 2
------------------------------------
SalesTeamId Email
12 test@test.com; test2@test.com
13 testA@test2.com; testB@test2.com


And the Result Are 2 Mail :
--------------------------------
(Mail 1)
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'Alert',
@recipients = 'test@test.com; test2@test.com',
@body = '20001B TEST Color 12 (90) (100)
20001B TEST Quantity 12 145 155',
@subject = 'Mail 1'


(Mail 2)
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'Alert',
@recipients = 'testA@test2.com; testB@test2.com',
@body = '20002B TEST Quantity 13 147 159',
@subject = 'Mail 2'

haroon2k9
Constraint Violating Yak Guru

328 Posts

Posted - 2009-11-05 : 07:03:10
pl look at this thread.

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

Go to Top of Page

kenlok
Starting Member

16 Posts

Posted - 2009-11-05 : 20:23:33
How can I write a query about "select" with the mail function?

Go to Top of Page
   

- Advertisement -