How to send email using sqlserver
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.
Step 3
The following window appears:
Click Next.
Step 4
Select the Set up Database Mail by performing the following tasks: radio button.
Step 5
Click Next, then a confirmation box appears; click OK on that.
Step 6
When you click OK, then write the profile name description and click on Add.
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.
Step 8
Then in the new window, it will show your profile, check that and click Next.
Step 9
Then in the new window, the Configure System Parameters description is shown.
Step 10
Click Next. It will show a confirmation about your profile; click Finish.
Step 11
Now the email service has been configured, click Close.
Step 12
Send a test email by right-clicking on database mail and click Send Test E-Mail.
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!!
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:
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.
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:
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

热AI工具

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

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

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

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

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

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

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

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

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

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

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