SQL Agent can be configured to use either its own internal mailing facilities based on MAPI or the Database Mail solution described earlier. Keep in mind that SQL Agent never uses legacy SQL Mail components, so when you look at the SQL Server Agent Properties dialog shown in Figure 10-9 the component name is slightly confusing. We will refer to SQL Agent MAPI mailer as SQL Agent Mail.
Figure 10-9. SQL Server Agent Properties dialogMail Session Configuration.
SQL Agent Mail, by default, targets extended MAPI for mail delivery, but when extended MAPI is not present, SQL Agent Mail starts using simple MAPI instead. Unlike SQL Mail, which runs in the context of the SQL Server Database Engine service account, SQL Agent Mail uses the SQL Agent service account because it is completely embedded within the SQL Agent internal process space.
When configuring SQL Agent to use Database Mail, you need to first pre-configure the Database Mail profile because SQL Agent expects explicit profile name specification at the configuration stage. SQL Agent uses Database Mail just as any other SQL Server client does: by executing the sp_send_dbmail stored procedure. However, if its corresponding SQL Server Database Engine instance is down and mail cannot be sent through this route, SQL Agent instead uses a low-level Database Mail API, using cached profile and account information. This way, mail still goes out in case of an emergency, but without being properly logged into MSDB repository along with other messages.