sysmail_update_account_sp (Transact-SQL)
Changes the information in an existing Database Mail account.
sysmail_update_account_sp [ [ @account_id = ] account_id ] [ , ] [ [ @account_name = ] 'account_name' ] ,
[ @email_address = ] 'email_address' ,
[ @display_name = ] 'display_name' ,
[ @replyto_address = ] 'replyto_address' ,
[ @description = ] 'description' ,
[ @mailserver_name = ] 'server_name' ,
[ @mailserver_type = ] 'server_type' ,
[ @port = ] port_number ,
[ @username = ] 'username' ,
[ @password = ] 'password' ,
[ @use_default_credentials = ] use_default_credentials ,
[ @enable_ssl = ] enable_ssl
When both the account name and the account id are specified, the stored procedure changes the account name in addition to updating the information for the account. Changing the account name may be useful to correct errors in the account name.
The stored procedure sysmail_update_account_sp is in the msdb database and is owned by the dbo schema. The procedure must be executed with a three-part name if the current database is not msdb.
A. Changing the information for an account
The following example updates the account AdventureWorks Administrator In the msdb database. The information for the account is set to the values provided.
EXECUTE msdb.dbo.sysmail_update_account_sp
,@account_name = 'AdventureWorks2008R2 Administrator'
,@description = 'Mail account for administrative e-mail.'
,@email_address = 'dba@Adventure-Works.com'
,@display_name = 'AdventureWorks Automated Mailer'
,@replyto_address = NULL
,@mailserver_name = 'smtp.Adventure-Works.com'
,@mailserver_type = 'SMTP'
,@port = 25
,@username = NULL
,@password = NULL
,@use_default_credentials = 0
,@enable_ssl = 0;
B. Changing the name of an account and the information for an account
The following example changes the name and updates the account information for the with account id 125. The new name of the account is Backup Mail Server.
EXECUTE msdb.dbo.sysmail_update_account_sp
,@account_id = 125
,@account_name = 'Backup Mail Server'
,@description = 'Mail account for administrative e-mail.'
,@email_address = 'dba@Adventure-Works.com'
,@display_name = 'AdventureWorks Automated Mailer'
,@replyto_address = NULL
,@mailserver_name = 'smtp-backup.Adventure-Works.com'
,@mailserver_type = 'SMTP'
,@port = 25,
,@username = NULL
,@password = NULL
,@use_default_credentials = 0
,@enable_ssl = 0;