Sql-server – Sending mail using DatabaseMail in SQL Server 2008

sql-server-2008

I have a profile called GPMail, and previously there was an account called comments@guitarplayer.com, which was working as expected.

Now I want one more account with the same site, so instead of creating new profile I created new account called password@guitarplayer.com inside the same profile. But now when I try to send mail for password, I do not get the option for the account in the stored procedure — sp_send_dbmail, so whenever I send the mail, the from field has the comments@guitarplayer.com address instead of password@guitarplayer.com.

Is there anyway that I can specify the account name too with Profile name while sending mails?

Best Answer

Depending on the method you use for sending mail: Yes

If you use sp_send_dbmail (which is what I use), then yes, you can set the FROM address in the call to send mail.

See docs: http://msdn.microsoft.com/en-us/library/ms190307.aspx

@from_address is what you want, I believe

If you want to actually log in to the mail server as a diff user, then you need to mod the profile or create a new one. The auth to the mail server is configured in the profile.