title: SQL profile name error when executing job
body: <p>I'm trying to make a scheduled job, so that on the day 25 of every month it sends an e-mail with some information. The code I have right now is:</p>
  
  <pre><code>EXEC msdb.dbo.sp_send_dbmail
            @profile_name = 'Main DB Mail profile',
            @recipients = 'myemail@mydomain.net',
            @subject = 'PG25',
            @query = N'SELECT CONVERT(date, docdata), adoc, nome, etotal, aprovado FROM fo
                       WHERE aprovado LIKE "0" 
                         AND pdata BETWEEN DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0) AND DATEFROMPARTS(YEAR(GETDATE()), MONTH(GETDATE()), 25)',
            @attach_query_result_as_file = 1,
            @query_attachment_filename = 'results.txt'
  </code></pre>
  
  <p>but when I execute this code I get this error:</p>
  
  <blockquote>
    <p>Msg 14607, Level 16, State 1, Procedure msdb.dbo.sysmail_verify_profile_sp, Line 42 [Batch Start Line 5]<br>
    Profile name is not valid</p>
  </blockquote>
  
  <p>Any thoughts on how I can get this to work?</p>