I had the same problem this morning, but with slightly different message...
Msg 22050, Level 16, State 1, Line 0
Error formatting query, probably invalid parameters
Msg 14661, Level 16, State 1, Procedure sp_send_dbmail, Line 478
Msg 208, Level 16, State 1, Server ServerName, Line 7
Invalid object name 'TableName'.
My problem was fixed when I added the 'Use DatabaseName' statement for each select statements in the @query text. Hope that also solve your problem...good luck.