sp_send_dbmail fails when run from a stored procedure
Posted on 2006-06-14
I have an app I'm moving from SQL Server 2k to 2k5. Several stored procedures in this app use sp_send_dbmail to send emails. I'm finding that I'm getting an error whenever the stored procedure tries to send the email, although using the sp_send_dbmail procedure works fine when run from code (e.g., as a SqlCommand). The error I get is:
The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 1 (2006-06-14T12:01:29). Exception Message: Cannot send mails to mail server. (The specified string is not in the form required for an e-mail address.).)
I've checked, and it's using a valid email address (firstname.lastname@example.org) format. It doesn't matter if I send the email in as a parameter or retrieve it within the stored procedure, or even type it in as a hard-coded varchar value; same error message results. There's no problem with the default profile; it sends emails just fine if you test it, and if an email is sent from within code.
Any idea why it's throwing such a fit about the format of the email address, and what I can do?