Results 1 to 2 of 2

Thread: xp_sendmail question

  1. #1
    Steve Renaker Guest

    xp_sendmail question

    Is it possible to use a SELECT statement for the @recipients field
    with xp_sendmail? What I want to do is get a list of email
    addresses from a table and send mail to them with xp_sendmail.

    Thanks,

    Steve Renaker
    srenaker@alexa.com

  2. #2
    Donnie Guest

    xp_sendmail question (reply)

    I don't think you can use a SELECT statement there.

    One really convoluted approach I came up with when trying to do a similar thing was something like this:

    declare @i int, @max_i int, @address varchar(255)

    SELECT
    identity(int,1,1) as id, email
    INTO #email
    FROM
    MyTable
    WHERE
    '.....'
    AND email is not null

    select @i = 1, @address = ''
    select @max_i = (select max(id) from #email)

    while @i <= @max_i
    BEGIN
    select @address = @address + (select email from #email where id = @i) + &#39;;&#39;
    select @i = @i + 1
    END

    exec master..xp_sendmail @recipients=@address, @message=&#39;this is a test message&#39;, @subject=&#39;hello..&#39;


    Good luck,
    Donnie

    ------------
    Steve Renaker at 9/21/99 2:28:21 PM

    Is it possible to use a SELECT statement for the @recipients field
    with xp_sendmail? What I want to do is get a list of email
    addresses from a table and send mail to them with xp_sendmail.

    Thanks,

    Steve Renaker
    srenaker@alexa.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •