目录
Introduction
Step 13
Note
Output Message
首页 数据库 mysql教程 How to send email using sqlserver

How to send email using sqlserver

Jun 07, 2016 pm 03:33 PM
email sqlserver using

This is from CodeProject:http://www.codeproject.com/Articles/846204/How-To-Send-Mail-Using-SQL-Server-Part Introduction There are three parts for this tutorial: Configure email profile and send test email using SQL Server Select and send d

This is from CodeProject:http://www.codeproject.com/Articles/846204/How-To-Send-Mail-Using-SQL-Server-Part

Introduction

There are three parts for this tutorial:

  • Configure email profile and send test email using SQL Server
  • Select and send data in mail
  • Schedule daily mail from SQL Server

Step 1

Log in to SQL Server 2008 with a correct user name and password.

Step 2

Expand the Management tab, then select SQL Server Logs, then right-click on Database Mail, then select Configure Database Mail.

How to send email using sqlserver

Step 3

The following window appears:

How to send email using sqlserver

Click Next.

Step 4

Select the Set up Database Mail by performing the following tasks: radio button.

How to send email using sqlserver

Step 5

Click Next, then a confirmation box appears; click OK on that.

How to send email using sqlserver

Step 6

When you click OK, then write the profile name description and click on Add.

How to send email using sqlserver

Step 7

Then, a new window appears where you provide your profile name and configure Outgoing Mail Server(SMTP) then click Basic authentication and provide your email id and password then click OK.

How to send email using sqlserver

Step 8

Then in the new window, it will show your profile, check that and click Next.

How to send email using sqlserver

Step 9

Then in the new window, the Configure System Parameters description is shown.

How to send email using sqlserver

Step 10

Click Next. It will show a confirmation about your profile; click Finish.

How to send email using sqlserver

Step 11

Now the email service has been configured, click Close.

How to send email using sqlserver

Step 12

Send a test email by right-clicking on database mail and click Send Test E-Mail.

How to send email using sqlserver

Step 13

Provide the Test Email Id and click On Send Test E-Mail. Then check your mail to see if you got the mail. Enjoy!!

How to send email using sqlserver

Note

After the Account and the Profile are created successfully, we need to configure the Database Mail. To configure it, we need to enable the Database Mail XPs parameter using the sp_configure Stored Procedure, as shown here:

How to send email using sqlserver Collapse | Copy Code

    sp_CONFIGURE <span>'</span><span>show advanced'</span>, <span>1</span>  
    <span>GO</span>  
    <span>RECONFIGURE</span>  
    <span>GO</span>  
    sp_CONFIGURE <span>'</span><span>Database Mail XPs'</span>, <span>1</span>  
    <span>GO</span>  
    <span>RECONFIGURE</span>  
    <span>GO</span>  
登录后复制

Output Message

The Configuration option "show advanced options" changed from 0 to 1. Run the RECONFIGURE statement to install.

The configuration option "Database Mail XPs" changed from 1 to 1. Run the RECONFIGURE statement to install.

Use the following query to send mail using query:

Send Mail Query

USE msdb;--Must Use msdb database, otherwise you will get error.

How to send email using sqlserver Collapse | Copy Code

    <span>GO</span>  
    <span>EXEC</span> sp_send_dbmail @profile_name=<span>'</span><span>MyTestMail'</span>,  
    @recipients=<span>'</span><span>manishki@live.com'</span>,  
    @subject=<span>'</span><span>My Test Mail Service.'</span>,  
    @body=<span>'</span><span>Database Mail Received Successfully.'</span>   
登录后复制

This is the body of this message.

Note

If you are using a database other than msdb, then use a stored procedure like msdb.dbo.sp_send_dbmail. The log can be checked in sysmail_log table as shown below:

How to send email using sqlserver Collapse | Copy Code

    <span>SELECT</span> * <span>FROM</span> sysmail_mailitems  
    <span>GO</span>  
    <span>SELECT</span> * <span>FROM</span> sysmail_log  
    <span>GO</span>  
    <span>select</span> * <span>from</span> sysmail_log  
登录后复制
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
2 周前 By 尊渡假赌尊渡假赌尊渡假赌
仓库:如何复兴队友
4 周前 By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒险:如何获得巨型种子
3 周前 By 尊渡假赌尊渡假赌尊渡假赌

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

sqlserver数据库中已存在名为的对象怎么解决 sqlserver数据库中已存在名为的对象怎么解决 Apr 05, 2024 pm 09:42 PM

对于 SQL Server 数据库中已存在同名对象,需要采取以下步骤:确认对象类型(表、视图、存储过程)。如果对象为空,可使用 IF NOT EXISTS 跳过创建。如果对象有数据,使用不同名称或修改结构。使用 DROP 删除现有对象(谨慎操作,建议备份)。检查架构更改,确保没有引用删除或重命名的对象。

​sqlserver怎么导入mdf文件 ​sqlserver怎么导入mdf文件 Apr 08, 2024 am 11:41 AM

导入步骤如下:将 MDF 文件复制到 SQL Server 的数据目录(通常为 C:\Program Files\Microsoft SQL Server\MSSQL\DATA)。在 SQL Server Management Studio(SSMS)中,打开数据库并选择“附加”。单击“添加”按钮,选择 MDF 文件。确认数据库名称,点击确定按钮即可。

sqlserver服务无法启动怎么办 sqlserver服务无法启动怎么办 Apr 05, 2024 pm 10:00 PM

当 SQL Server 服务无法启动时,可采取以下步骤解决:检查错误日志以确定根本原因。确保服务帐户具有启动服务的权限。检查依赖项服务是否正在运行。禁用防病毒软件。修复 SQL Server 安装。如果修复不起作用,重新安装 SQL Server。

怎么查看sqlserver端口号 怎么查看sqlserver端口号 Apr 05, 2024 pm 09:57 PM

要查看 SQL Server 端口号:打开 SSMS,连接到服务器。在对象资源管理器中找到服务器名称,右键单击它,然后选择“属性”。在“连接”选项卡中,查看“TCP 端口”字段。

sqlserver误删数据库怎么恢复 sqlserver误删数据库怎么恢复 Apr 05, 2024 pm 10:39 PM

若误删 SQL Server 数据库,可采取以下步骤恢复:停止数据库活动;备份日志文件;检查数据库日志;恢复选项:从备份恢复;从事务日志恢复;使用 DBCC CHECKDB;使用第三方工具。请定期备份数据库并启用事务日志以防止数据丢失。

sqlserver数据库在哪里 sqlserver数据库在哪里 Apr 05, 2024 pm 08:21 PM

SQL Server 数据库文件通常存储在以下默认位置:Windows: C:\Program Files\Microsoft SQL Server\MSSQL\DATALinux: /var/opt/mssql/data可通过修改数据库文件路径设置来自定义数据库文件位置。

Python如何使用email、smtplib、poplib、imaplib模块收发邮件 Python如何使用email、smtplib、poplib、imaplib模块收发邮件 May 16, 2023 pm 11:44 PM

一封电子邮件的旅程是:MUA:MailUserAgent——邮件用户代理。(即类似Outlook的电子邮件软件)MTA:MailTransferAgent——邮件传输代理,就是那些Email服务提供商,比如网易、新浪等等。MDA:MailDeliveryAgent——邮件投递代理。Email服务提供商的某个服务器发件人->MUA->MTA->MTA->若

Java连接SqlServer错误如何解决 Java连接SqlServer错误如何解决 May 01, 2023 am 09:22 AM

问题发现这次使用的是SqlServer数据库,之前并没有使用过,但是问题不大,我按照需求文档的步骤连接好SqlServer之后,启动SpringBoot项目,发现了一个报错,如下:刚开始我以为是SqlServer连接问题呢,于是便去查看数据库,发现数据库一切正常,我首先第一时间问了我的同事,他们是否有这样的问题,发现他们并没有,于是我便开始了我最拿手的环节,面向百度编程。开始解决具体报错信息是这样,于是我便开始了百度报错:ERRORc.a.d.p.DruidDataSource$CreateCo

See all articles