Posted - 09/15/2013 : 05:33:37
| Hi All,
For the last several days I'm trying to resolve issue with sending emails by following procedure (I've ommited some parts):
SELECT @Subj = 'New ' + @ListType + ' Release in ''' + @Product + ' ' + @Country + ''' ' + @StatusChange
@recipients = @EMail,
@copy_recipients = @CCMail,
@subject = @Subj
If in @Product variable is whitespace (from query from other table) i.e oranges (white) the email is not being sent with error message as follow:
"The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account Exception Message: Cannot send mails to mail server. (The specified string is not in the form required for a subject.).)". It seems that the message cannot be sent if there is a whitespace in the variable, but on the other hand if I change query:
SELECT @Subj = 'New ' + @ListType + ' Release in ''' + ' oranges (white) ' + ' ' + @Country + ''' ' + @StatusChange
No problem with sending email. Also if I assign the string directy to @subject there is no issue with sending emails too. If there is not white spaces in variable @Product everything is working fine...
I've already tried several different approaches to resolve that issue but still no success (and reviewed a tons of entries on different forums...):
1. On one of the forums I found to check SQLAgent entry regarding account for sending email - didn't resolve the issue
2. Restarting server/services - didn't help
3. Do a cast on @product variable Cast(@product as CHAR(25)) the same issue occures
4. Assign the @subj variable to different variable and the latter one use as the @subject - didn't help
OS: win 2008 std x86
SQL: 2008 std x86 (with all current updates)
Messaging server: Exchange 2010 (with all current sp's and updates)
Telnet: working fine...
No problem to send test email. No other issues from SQL end...
Thanks for Your help on that!