It doesn't work. I this error:
Msg 18025, Sev 16: xp_sendmail: failed with mail error 0x80070005 [SQLSTATE 42000]
The job works well when this part is commented out.
Does it happen every time ? Execute xp_sendmail, twice - back to back and see if it still happens. We had this occur on our box - but the error normally only appeared once and then subsequent calls to xp_sendmail worked fine. Let me know.
The gelatinous cube that is microsoft will not reveal the answer - it is like poking the sleeping dragon to get his lazy butt to wake up. Butt seriously, I think it is just an initialization problem (because it will probably rear its ugly head again, not immediately though) - it could be just that something gets corrupted the first time the object is invoked
or a timing issue where the credentials beat the instantiation of the object. Anyway, make sure that where you use the xp_sendmail to have an error trap - or just have xp_sendmail run periodically that sends something back to you to make sure it doesn't nod off again.