November 15, 2011 at 6:47 am
Database Mail is disabled for security reasons.
I have used the ActiveX Script in DTS to send SMTP Mail.
Does anyone have a clean example on how to do this in T-SQL?
Any help would be greatly appreciated.
Thanks.
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
November 15, 2011 at 7:21 am
I found the following, testing from my PC:
REATE PROCEDURE sp_SMTPMail
@SenderName VARCHAR(100),
@SenderAddress VARCHAR(100),
@RecipientName VARCHAR(100),
@RecipientAddress VARCHAR(100),
@Subject VARCHAR(200),
@Body VARCHAR(8000)
AS
SET NOCOUNT ON
DECLARE @oMail INT --Object reference
DECLARE @resultcode INT
EXEC @resultcode = sp_OACreate 'CDONTS.NewMail',
@oMail OUT
IF @resultcode = 0
BEGIN
EXEC @resultcode = sp_OASetProperty @oMail, 'From', @SenderAddress
EXEC @resultcode = sp_OASetProperty @oMail, 'To', @RecipientAddress
EXEC @resultcode = sp_OASetProperty @oMail, 'Subject', @Subject
EXEC @resultcode = sp_OASetProperty @oMail, 'Body', @Body
EXEC @resultcode = sp_OAMethod @oMail, 'Send', NULL
EXEC sp_OADestroy @oMail
END
SET NOCOUNT OFF
GO
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
November 15, 2011 at 8:05 am
Database Mail disabled for security reasons?
And OLE automation enabled instead?
Weird, I would do the exact opposite.
-- Gianluca Sartori
November 15, 2011 at 8:17 am
Gianluca Sartori (11/15/2011)
Database Mail disabled for security reasons?And OLE automation enabled instead?
Weird, I would do the exact opposite.
Yes, I agree but sometimes you can't convince someone that that is the way to go.:w00t:
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
November 15, 2011 at 1:27 pm
Way back in SQL Server 2000 we used a product called AspEmail from Persits. It just installs as a COM object that can be called with the sp_OA procedures and offered more options that CDONTS. But basically the implementation was the same as what you've done. I haven't gotten to use Database Mail as we moved away from having our stored procs send any email and doing it at another layer.
Cliff
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply