TRANSACTION XP_SENDMAIL

  • Hi,

    I having problems trapping a sendmail error. If XP_sendmail fails @@error is still 0. I need to run an update but only if the mail has been sent succesfully.

    Please help many thanks

  • Can you post your code?

    If memory serves, xp_sendmail only returns a 0 or 1, and it considers 0 a success. I don't believe it populates the @@Error variable, as it considers the 0 and 1 a return value, not an error necessarily.

  • This is what I would do:

    DECLARE @xp_status tinyint

    EXEC @xp_status = master.dbo.xp_sendmail 'Recipient@email.here.com'

    , @Subject = 'This is the Subject'

    , @message = 'This is the Body.'

    select @xp_status

    P.S. One of the XPs (I don't remember which one off hand) returns the 0/1, but as a character, so I use a varchar(1) for that one.

Viewing 3 posts - 1 through 2 (of 2 total)

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