blu*_*rth 2 sql-server sql-server-2012 sql-server-express database-mail
我需要在我的项目中使用 SQL Server 数据库邮件功能。但是数据库邮件在我的开发实例上似乎不可用。
对象资源管理器中应该有一个“数据库邮件”节点。在此屏幕截图中,我似乎找不到任何内容。还显示了我的 SQL Server 版本。
此 SQL Server 版本不支持数据库邮件吗?使用数据库邮件需要哪个 SQL Server 版本(或版本)?
我可以在网上找到的所有文档总是假设该功能已经安装,然后继续解释如何配置它。如果我的 SQL Server 版本支持数据库邮件,如何安装/启用该功能?
您可以将 SQL Mail 与 SQL Server Express 版本一起使用。
从使用 SQL Server Express Edition 发送邮件中大量借用
要配置 SQL 邮件,我们需要按照以下步骤操作。
--Create Sysmail Account
--Use sysmail_add_account_sp stored procedure of MSDB database to configure sysmail account.
EXECUTE msdb.dbo.sysmail_add_account_sp
@account_name = 'MailTest',
@description = 'Sent Mail using MSDB',
@email_address = 'YourEmail@test.com',
@display_name = 'DisplayName',
--@username='umashankar@queryingsql.com',
--@password='password',
@mailserver_name = 'mail.server.com'
--Creating Database Profile
--Use sysmail_add_profile_sp stored procedure of MSDB database to configure Database Profile.
EXECUTE msdb.dbo.sysmail_add_profile_sp
@profile_name = 'MailTest',
@description = 'Profile used to send mail'
--Add database Mail account to profile
--Use sysmail_add_profileaccount_sp stored procedure of MSDB database to map database mail account to Profile.
EXECUTE msdb.dbo.sysmail_add_profileaccount_sp
@profile_name = 'MailTest',
@account_name = 'MailTest',
@sequence_number = 1
--Grants permission for a database user or role to use a Database Mail profile.
--To Grant permission for a database user or role to use a Database Mail profile use sysmail_add_principalprofile_sp.
EXECUTE msdb.dbo.sysmail_add_principalprofile_sp
@profile_name = 'MailTest',
@principal_name = 'public',
@is_default = 1 ;
--Enable 'Database Mail XPs'.
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Database Mail XPs', 1;
GO
RECONFIGURE
GO
--Send Mail using Created Profile
exec msdb.dbo.sp_send_dbmail @profile_name = 'MailTest', @recipients = 'receiver@queryingsql.com', @subject = 'Mail Test', @body = 'Mail Sent Successfully', @body_format = 'text'
Run Code Online (Sandbox Code Playgroud)
我会说 SQL Mail 已被弃用,可能会在 SQL Server Express 的未来版本中删除,但它似乎在最新版本中仍然有效。
| 归档时间: |
|
| 查看次数: |
598 次 |
| 最近记录: |