目次
Introduction
Step 13
Note
Output Message

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 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

AI Hentai Generator

AI Hentai Generator

AIヘンタイを無料で生成します。

ホットツール

メモ帳++7.3.1

メモ帳++7.3.1

使いやすく無料のコードエディター

SublimeText3 中国語版

SublimeText3 中国語版

中国語版、とても使いやすい

ゼンドスタジオ 13.0.1

ゼンドスタジオ 13.0.1

強力な PHP 統合開発環境

ドリームウィーバー CS6

ドリームウィーバー CS6

ビジュアル Web 開発ツール

SublimeText3 Mac版

SublimeText3 Mac版

神レベルのコード編集ソフト(SublimeText3)

指定されたオブジェクトが sqlserver データベースにすでに存在するという問題を解決する方法 指定されたオブジェクトが sqlserver データベースにすでに存在するという問題を解決する方法 Apr 05, 2024 pm 09:42 PM

SQL Server データベースに既に存在する同じ名前のオブジェクトについては、次の手順を実行する必要があります。 オブジェクトの種類 (テーブル、ビュー、ストアド プロシージャ) を確認します。 IF NOT EXISTS を使用すると、オブジェクトが空の場合に作成をスキップできます。オブジェクトにデータがある場合は、別の名前を使用するか、構造を変更してください。既存のオブジェクトを削除するには、DROP を使用します (注意してください。バックアップを推奨します)。スキーマの変更をチェックして、削除または名前変更されたオブジェクトへの参照がないことを確認します。

mdfファイルをsqlserverにインポートする方法 mdfファイルをsqlserverにインポートする方法 Apr 08, 2024 am 11:41 AM

インポート手順は次のとおりです。 MDF ファイルを SQL Server のデータ ディレクトリ (通常は C:\Program Files\Microsoft SQL Server\MSSQL\DATA) にコピーします。 SQL Server Management Studio (SSMS) でデータベースを開き、[アタッチ] を選択します。 「追加」ボタンをクリックして、MDF ファイルを選択します。データベース名を確認し、「OK」ボタンをクリックします。

sqlserver サービスを開始できない場合の対処方法 sqlserver サービスを開始できない場合の対処方法 Apr 05, 2024 pm 10:00 PM

SQL Server サービスの開始に失敗した場合の解決手順は次のとおりです。 エラー ログを確認して、根本原因を特定します。サービス アカウントにサービスを開始する権限があることを確認してください。依存関係サービスが実行されているかどうかを確認します。ウイルス対策ソフトウェアを無効にします。 SQL Server のインストールを修復します。修復が機能しない場合は、SQL Server を再インストールします。

SQLサーバーのポート番号を確認する方法 SQLサーバーのポート番号を確認する方法 Apr 05, 2024 pm 09:57 PM

SQL Server のポート番号を表示するには: SSMS を開いてサーバーに接続します。オブジェクト エクスプローラーでサーバー名を見つけ、右クリックして [プロパティ] を選択します。 「接続」タブで、「TCP ポート」フィールドを表示します。

sqlserverで誤って削除したデータベースを回復する方法 sqlserverで誤って削除したデータベースを回復する方法 Apr 05, 2024 pm 10:39 PM

SQL Server データベースを誤って削除した場合は、次の手順を実行して回復できます: データベース アクティビティの停止、ログ ファイルのバックアップ、データベース ログの確認、回復オプション: バックアップからの復元、トランザクション ログからの復元、DBCC CHECKDB の使用、3 番目の使用パーティーツール。データ損失を防ぐために、データベースを定期的にバックアップし、トランザクション ログを有効にしてください。

SQLserver データベースはどこにありますか? SQLserver データベースはどこにありますか? Apr 05, 2024 pm 08:21 PM

SQL Server データベース ファイルは、通常、次のデフォルトの場所に保存されます。 Windows: C:\Program Files\Microsoft SQL Server\MSSQL\DATALinux: /var/opt/mssql/data データベース ファイルの場所は、データベース ファイル パスを変更することでカスタマイズできます。設定。

電子メール、smtplib、poplib、imaplib モジュールを使用して Python で電子メールを送受信する方法 電子メール、smtplib、poplib、imaplib モジュールを使用して Python で電子メールを送受信する方法 May 16, 2023 pm 11:44 PM

電子メールの流れは次のとおりです: MUA: MailUserAgent - メール ユーザー エージェント。 (つまり、Outlook に似た電子メール ソフトウェア) MTA: MailTransferAgent - メール転送エージェント。NetEase、Sina などの電子メール サービス プロバイダーです。 MDA: MailDeliverAgent - メール配信エージェント。電子メール サービス プロバイダーのサーバー sender->MUA->MTA->MTA->if

Java接続のSqlServerエラーを解決する方法 Java接続のSqlServerエラーを解決する方法 May 01, 2023 am 09:22 AM

今回問題が判明したのは、これまで使用したことのない SqlServer データベースを使用していたことですが、問題は深刻ではありませんでした。要件文書の手順に従って SqlServer に接続した後、SpringBoot プロジェクトを開始すると、次のようなエラーが発生しました: 最初は SqlServer 接続だと思いました。問題があったので、データベースを確認しに行きましたが、すべてが正常であることがわかりました。最初に同僚にそのような問題があるかどうか尋ねたところ、彼らがそうでなかったので、Baidu プログラミングに取り組むという私の最も得意な部分を始めました。私が解決し始めた具体的なエラー メッセージは次のとおりでした。そこで、Baidu のエラー レポートを開始しました: ERRORc.a.d.p.DruidDataSource$CreateCo

See all articles