Results 1 to 6 of 6

Thread: xp_sendmail

  1. #1
    Join Date
    Nov 2003
    Location
    London
    Posts
    169

    Unanswered: xp_sendmail

    Hi,

    I want to use xp_sendmail like this

    declare @user varchar
    select @user = user
    from users
    where userid =1


    exec.xp_sendmail @user, 'The master database is full.'



    But I get an error message saying ambiguous recipient

    Is there any way I cn do this?

  2. #2
    Join Date
    Mar 2004
    Posts
    18
    What is the value of user in the users table.
    It has to be a valid email address.
    First try entering a hardcoded email adddress and check whether u can send the mail.

    Regards
    Jay

  3. #3
    Join Date
    Nov 2003
    Location
    London
    Posts
    169
    Yes it is a valid email address and I have many xp_senmails with hard coded email adresses,

    I just want to use a parameter, can it be done?

  4. #4
    Join Date
    Mar 2004
    Posts
    18
    yes it can be done, it don't knw why it is not coming to you.
    What is the exact error code and message you are getting ?

  5. #5
    Join Date
    Apr 2003
    Location
    Edison, NJ / Oakland, NJ (Work)
    Posts
    32

    I can't get it to work either

    He's probably getting the same as I do. I thought that I'd be able to do it, but I cannot. Nor can I find ANYTHING online that refers to using variables as this value. Every example I find has the string in the execution of the procedure.


    Code:
    DECLARE @useremail nvarchar
    
    SET @useremail = 'user'
    
    BEGIN
    USE master
    EXEC xp_sendmail 
                    @recipients = @useremail
                  , @subject = 'DATABASE ERROR LEVEL 1'
                  , @message = 'The master database is full. This is bad.'
    END
    ERROR
    Server: Msg 18032, Level 16, State 1, Line 0
    xp_sendmail: Recipient is ambiguous

    I've tried many different variations (including the one-liner without using the built-in variable names) to get this to work with no success. Good Luck!
    Last edited by smithhayward; 06-23-04 at 13:12.
    -----------------------------------
    Smith Hayward
    -----------------------------------

  6. #6
    Join Date
    Nov 2003
    Location
    London
    Posts
    169
    Yes that's exactly error I am getting, hmm why doesn't it work.

    Could you use a query like this:






    exec.xp_sendmail 'select @user = user
    from users
    where userid =1', 'The master database is full.'


    The reason I need to do this is that once a user has performed a set function then I would my database to email them confirming that their action has succeded.

Posting Permissions

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