title: Mail sent through SQL Server Express - Mail (Id: 17) queued
body: <p>I followed a guide online, to send a mail through SQL Server Express, but it keeps saying "Mail (Id: 1) queued.", and up to 17, as I have tried 17 times now.</p>
  
  <p>The email is a dummy mail, and not my real one. It is just an example. I use my real mail in the SQL Server Management Studio. SQL Server Express as my teacher called it.</p>
  
  <p>First part of code (To create sysmail account)</p>
  
  <pre><code>EXECUTE msdb.dbo.sysmail_add_account_sp
      @account_name = 'MailTest',
      @description = 'Sent Mail using MSDB',
      @email_address = 'testmail@mail.com',
      @display_name = 'Landlyst',
      @username='testmail@mail.com',
      @password='password',
      @mailserver_name = 'mail.google.com'
  </code></pre>
  
  <p>Second part of code (To create Database Profile)</p>
  
  <pre><code>EXECUTE msdb.dbo.sysmail_add_profile_sp
      @profile_name = 'MailTest',
      @description = 'Profile used to send mail'
  </code></pre>
  
  <p>Third part of code (To add database Mail account to profile)</p>
  
  <pre><code>EXECUTE msdb.dbo.sysmail_add_profileaccount_sp
      @profile_name = 'MailTest',
      @account_name = 'MailTest',
      @sequence_number = 1
  </code></pre>
  
  <p>Fourth part of code (Grants permission to all)</p>
  
  <pre><code>EXECUTE msdb.dbo.sysmail_add_principalprofile_sp
      @profile_name = 'MailTest',
      @principal_name = 'public',
      @is_default = 1 ;
  </code></pre>
  
  <p>Fifth part of code (to enable the program to send mail, and not give an error)</p>
  
  <pre><code>sp_configure 'show advanced options', 1;
  GO
  RECONFIGURE;
  GO
  sp_configure 'Database Mail XPs', 1;
  GO
  RECONFIGURE
  GO
  </code></pre>
  
  <p>Sixth part of code (To send the test mail)</p>
  
  <pre><code>EXEC msdb.dbo.sp_send_dbmail 
       @profile_name = 'MailTest', 
       @recipients = 'receiver@queryingsql.com', 
       @subject = 'Mail Test', 
       @body = 'Mail Sent Successfully', 
       @body_format = 'text'
  </code></pre>
  
  <p>I am not very good at SQL, but I need this to work as a trigger on a user.
  Could someone please help me with this?</p>
  
  <p><a href="http://www.sqlservercentral.com/blogs/querying-microsoft-sql-server/2013/09/02/sending-mail-using-sql-server-express-edition/" rel="nofollow">Source</a></p>