Removes an account from a Database Mail profile.
Returns an error if the account specified is not associated with the profile specified.
When an account is specified but no profile is specified, this stored procedure removes the specified account from all profiles. For example, if you are preparing to shut down an existing SMTP server, you remove accounts that use that SMTP server from all profiles, rather than removing each account from each profile.
When a profile is specified but no account is specified, this stored procedure removes all accounts from the specified profile. For example, if you are changing the SMTP servers a profile uses, it may be convenient to remove all accounts from the profile and then add new accounts as necessary.
The stored procedure sysmail_delete_profileaccount_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.
The following example shows removing the account Audit Account from the profile AdventureWorks2008R2 Administrator.
EXECUTE msdb.dbo.sysmail_delete_profileaccount_sp @profile_name = 'AdventureWorks2008R2 Administrator', @account_name = 'Audit Account' ;