|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-05-02 : 10:26:40
|
| sun writes "hi, i have a job which executes stored procedure. this stored procedure has the cdonts mail method to send the mail when the time is scheduled. this time scheduled is taken from a field in the database. now, when i send the mail, the mail is going but i want it to be bful with cosmetic changes ie. in html format. But since i am using sp_OAMethod. the code used is as follows: --------------------------REATE PROCEDURE mailfired ASDeclare @tomail varchar(30), @nowd int, @nowm char, @nowy int, @nmd datetime, @mf int, @reocc intDeclare @sub varchar(50), @mess varchar(500)Declare @thend int, @thenm char, @theny intset @nowd=day(getdate())set @nowm=month(getdate())set @nowy=year(getdate())DECLARE sor CURSOR FORselect userinfo.email, reminderinfo.subject, message, newmaildate, mailfired, reoccurance from reminderinfo join userinfoon userinfo.email=reminderinfo.email where @nowd=datepart(day, newmaildate)and @nowm=datepart(month, newmaildate) and @nowy=datepart(year, newmaildate) and reoccurance != 0or @nowd=datepart(day, newmaildate) and maildate = newmaildate and MailFired = 0OPEN sorFETCH NEXT FROM sor into @tomail, @sub, @mess, @nmd, @mf, @reoccWHILE @@FETCH_STATUS = 0BEGIN DECLARE @result INT EXEC @result = SP_CDONTS_NewMail_Send 'info@4kismet.com', @tomail,@sub,@mess PRINT @result WAITFOR DELAY '000:00:10'set @mf = @mf + 1set @nmd =(@nmd + @mf + (@reocc-@mf))update reminderinfo set newmaildate = @nmd, mailfired = @mf where reminderinfo.email = @tomail and@nowd=datepart(day, newmaildate) and @nowm=datepart(month, newmaildate) and @nowy=datepart(year, newmaildate)and subject = @sub and message = @messFETCH NEXT FROM sor into @tomail, @sub, @mess, @nmd, @mf, @reoccENDCLOSE sorDEALLOCATE sor---------------------------------------and the next stored procedure is:-------------------------------------------------------CREATE PROCEDURE SP_CDONTS_NewMail_Send @from VARCHAR(8000), @to VARCHAR(8000), @subject VARCHAR(8000), @body VARCHAR(8000)ASDECLARE @result INTDECLARE @object INTPRINT 'Creating the CDONTS.NewMail object'EXEC @result = sp_OACreate 'CDONTS.NewMail', @object OUTPUTIF @result <> 0BEGIN PRINT 'sp_OACreate Failed' RETURN @resultENDPRINT 'Sending the message using the Send method'EXEC @result = sp_OAMethod @object, 'Send', NULL, @from, @to, @subject, @bodyIF @result <> 0BEGIN PRINT 'sp_OAMethod Failed' RETURN @resultENDPRINT 'Destroying the CDONTS.NewMail object'EXEC @result = sp_OADestroy @objectIF @result <> 0BEGIN PRINT 'sp_OADestroy Failed' RETURN @resultENDRETURN 0-------------------------------------------------------- Please suggest how to use html tags in @body variable. thanxsun" |
|