Webmaster Forums Banner Professional Hosting from Just Host
Welcome Guest Search | Active Topics | Members | Log In | Register

email using MS Sql Options
kirshana
Posted: Thursday, May 01, 2008 5:32:33 AM
Rank: Advanced Member
Groups: Member

Joined: 1/31/2008
Posts: 80
Points: 143
Location: India
Can you anyone help or point me out to the link that can help as to how to send emails by the stored procedures of MS SQL server?

Thanks in advance!
Sponsor
Posted: Thursday, May 01, 2008 5:32:33 AM
ca4nul
Posted: Wednesday, May 28, 2008 6:12:11 AM

Rank: Advanced Member
Groups: Member

Joined: 11/9/2007
Posts: 223
Points: 575
Location: UK
CREATE Procedure sn_SMTPMail
/*********************************************************************
** Simon / Lavanya
**
** PURPOSE:
** This stored procedure is used to send email from MS SQL Database
**
** TABLE USED:
** TEMP
** RESULT:
** Email Sent.
** Command:
** exec sn_SMTPMail
**********************************************************************/
AS
SET nocount on
declare @oMail int --Object reference
declare @resultcode int
EXEC @resultcode = sp_OACreate 'CDONTS.NewMail', @oMail OUT
if @resultcode = 0
BEGIN
DECLARE @t int
DECLARE cur CURSOR FOR Select id from temp where checkrecord = 'Y' and termdate > getdate() - 10
OPEN cur
FETCH NEXT FROM cur INTO @t
WHILE @@FETCH_STATUS = 0 BEGIN
EXEC @resultcode = sp_OASetProperty @oMail, 'From', 'lavanyasimon@yahoo.com'
EXEC @resultcode = sp_OASetProperty @oMail, 'To', 'simonnadar@yahoo.com'
EXEC @resultcode = sp_OASetProperty @oMail, 'Subject', @t
EXEC @resultcode = sp_OASetProperty @oMail, 'Body', 'ID Expires in next 10 days. Please Take Appropriate Action'
EXEC @resultcode = sp_OAMethod @oMail, 'Send', NULL
EXEC sp_OADestroy @oMail
FETCH NEXT FROM cur INTO @t
END
CLOSE cur
DEALLOCATE cur
END
SET nocount off
GO
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

ASPNET Theme created by Boskone (Dan Ferguson)
Powered by HaqTech.Com
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.
This page was generated in 1.690 seconds.