SQL Server Performance

xp_sendmail: failed with mail error 0x80004005

Discussion in 'General DBA Questions' started by deepakontheweb, Jul 18, 2005.

  1. deepakontheweb New Member


    I have recently changed SQL Logon domain user expample: from aax1 to aax2.. Now aax2 is being used for running sql and agent services.

    There used to be a MAPI profile on server by the name sql1 that has been removed and new profile created by the name sql2. Now I have added sql2 profile in 'SQL Mail'. changed SQL Agent Mail session to be run using sql2 profile..recreated operator and tested.. it is sending emails.

    But when i am executing xp_sendmail from query analyzer [checked with 'sa' account/ windows authentication].. it is showing below error all the time: -


    EXEC master..xp_sendmail
    @recipients='xxx@zzz.com',
    @message = 'test'

    Error: -

    Server: Msg 18025, Level 16, State 1, Line 0
    xp_sendmail: failed with mail error 0x80004005


    What went wrong? any idea...


    Deepak Kumar

    --An eye for an eye and everyone shall be blind
  2. Madhivanan Moderator

    Try this

    CREATE PROCEDURE SendMail(
    @From varchar(255),
    @To varchar(255),
    @Message varchar(8000),
    @Subject varchar(255))
    AS

    DECLARE @CDO int, @OLEResult int, @Out int

    --Create CDONTS.NewMail object
    EXECUTE @OLEResult = sp_OACreate 'CDONTS.NewMail', @CDO OUT
    IF @OLEResult <> 0 PRINT 'CDONTS.NewMail'


    EXECUTE @OLEResult = sp_OASetProperty @CDO, 'BodyFormat', 0
    EXECUTE @OLEResult = sp_OASetProperty @CDO, 'MailFormat', 0

    --Call Send method of the object
    execute @OLEResult = sp_OAMethod @CDO, 'Send', Null, @From, @To, @Subject, @Message, 1 --0 is low 1 is normal
    IF @OLEResult <> 0 PRINT 'Send'

    --Destroy CDO
    EXECUTE @OLEResult = sp_OADestroy @CDO

    return @OLEResult


    Madhivanan

    Failing to plan is Planning to fail
  3. deepakontheweb New Member


    -- Forgot to write that.. I have checked after restarting SQL Agent services and removed all old sent/inbox items from emails. BUT can not take 1 min downtime to restart whole Server.

    Ahhh.. there were a lot content to read for similar error on web, but nothing like that is matching with my problem situation.



    Deepak Kumar

    --An eye for an eye and everyone shall be blind
  4. deepakontheweb New Member

    <blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by Madhivanan</i><br /><br />Try this<br /><pre id="code"><font face="courier" size="2" id="code">CREATE PROCEDURE SendMail( <br /><br /> <br />return @OLEResult </font id="code"></pre id="code"><br /><br /><br />Madhivanan<br /><br />Failing to plan is Planning to fail<br /><hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote"><br /><br /><br />This is OK.. I can use this... But I am more intrested to know what went wrong..what did I miss.. ??<br /><br />Thanks for your quick reply <img src='/community/emoticons/emotion-1.gif' alt=':)' /><br /><br /><br />Deepak Kumar<br /><br />--An eye for an eye and everyone shall be blind
  5. Madhivanan Moderator

  6. deepakontheweb New Member



    Already tried with "exec master.dbo.xp_stopmail" but No Luck !!




    Deepak Kumar

    --An eye for an eye and everyone shall be blind
  7. Argyle New Member

  8. danan_xu New Member

    I have similar problem with one of our production servers as well.

  9. deepakontheweb New Member



    Have you tried this after restarting database server..??

    I am facing this problem on Win 2003 Ent Edition server.. Outlook 2002, SQL 2000 Ent Ed+ Sp3a.



    quote:Originally posted by danan_xu

    I have similar problem with one of our production servers as well.



    Deepak Kumar

    --An eye for an eye and everyone shall be blind
  10. deepakontheweb New Member


    Champs : Any idea how to resolve it.. what is causing this problem??



    Deepak Kumar

    --An eye for an eye and everyone shall be blind
  11. deepakontheweb New Member


    Is there any way other then reinstalling Outlook??



    Deepak Kumar

    --An eye for an eye and everyone shall be blind
  12. deepakontheweb New Member

    <br />Thanks Argyle, I have got solution.. Sorry for replying so late <img src='/community/emoticons/emotion-5.gif' alt=';-)' /><br /<a target="_blank" href=http://support.microsoft.com/kb/293422/EN-US/>http://support.microsoft.com/kb/293422/EN-US/</a> help me to rectify it..<br /><br />"danan_xu" You can also try with below steps..<br /><br /><br />1. Open the Active Directory Users and Computers Snap-In. <br />2. Locate the user object directly associated with the Exchange 2000 mailbox and select it. <br />3. Right-click to get the properties for this account or mailbox object. <br />4. Click the Security tab. (If the Security tab is not showing, select Advanced Features from the View menu; this will show the Security tab.) <br />5. In the Security dialog box, click Advanced. <br />6. In the Access Control Settings for XXX dialog box, click ADD. <br />7. Locate, and then select the Active Directory account that the MSSQLServer service is logging in as. <br />8. Make sure that the Allow Onto list box is set to This object and all child objects. <br />9. In the Permission Entry for XXX dialog box, scroll down in the Permission pane, and under the Allow column, select Send As. <br />10. Press OK three (3) times to apply the change on all the open dialog boxes. <br /><br /><br />Deepak Kumar<br /><br />--An eye for an eye and everyone shall be blind
  13. chetanjain04 Member

    Hi,

    I have seen the http://support.microsoft.com/kb/293422/EN-US/ link. According to MS this error applies to SQL Server Standard Edition. However, I am having SQL Enterprise +SP3 and I am frequently getting such errors in scheduled jobs. These jobs are using xp_sendmail to send mails. I have gone through many articles on the net but to no success. If anybody facing the same problem on Enterprise Ed. +SP3 pls. let me know

    Regards,

    Chetan Jain
  14. Argyle New Member

    It would apply to all SQL 2000 editions since the solution to the problems is outside the scope of SQL Server. It has to do with setting the correct rights in Active Directory ("Send As" rights on the Exchange 2000 mailbox object in the Active Directory)
  15. chetanjain04 Member

    Thanks Argyle for your quick response.[8D] But I am wondering why MS is not giving proper info. Anyways, I will try this and hope it works for me.


    Regards,

    Chetan Jain.
  16. HansLindgren New Member

    Hello,
    The thread is a bit old but thought to contribute that you can get the same
    Server: Msg 18025, Level 16, State 1, Line 0
    xp_sendmail: failed with mail error 0x80004005
    error if the Mail Store is full. I.e. when you empty it, all is good in wonderland again!
    Regards,
    hanslindgren
  17. Sig New Member

    If you are trying to add an attachment to the email make sure what you are attaching actually exists. A non existent file will cause this error.

Share This Page