What''s wrong with part of the procedure?

  • I have next(part of the procedure):

    IF @Total > 0

              BEGIN

                   DECLARE cur_email CURSOR FOR

                   select Email from GroupMember a INNER JOIN userinfo b ON a.Member=b.UserName INNER JOIN UserAuthentication c ON b.userName = c.UserName WHERE groupname = 'PDC Member' AND b.UserName != 'admin' AND b.Email != '' AND c.AccountIsActive = 1

                   OPEN cur_email

                   FETCH NEXT FROM cur_email into @Email

                   WHILE @@FETCH_STATUS = 0

                   BEGIN

                        SELECT @Body = ('test test me')

                             exec @rc = master.dbo.xp_smtp_sendmail

                                  @FROM               = N'admin@mydomain.com',

                                  @FROM_NAME          = N'ADMIN',

                                  @TO               = @Email,

                                  @subject          = N'Hi there',

                                  @message          = @Body,

                                  @type               = N'text/html',

                                  @server           = @EmailServer

                             SELECT RC = @rc      

                   FETCH NEXT FROM cur_email into @Email

                   END

              SET @Body = ''

              END

         ELSE PRINT 'Failed to send an Email'

    @Total is bigger than 0 - i checked... there is 2 emails it's suppose to pick-up with fetch it into @email and send both emails out.

    But it won't do it. I made it work for one email w/ FETCH... but we have multiple emails to send out....

    any ideas why it won't work?

  • What is the line

    SELECT RC = @rc

    ?

  • that's just a part of sp_smtp_email thingy...

    it returns 1 or 0. When it returns 1 - nothing was sent, 0 - when it was sent successfuly

  • Nevermind everyone =) I made it work

  • What was your solution? (It might help someone else at a later date).

    -SQLBill

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply