* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Configuring SQLMail or Database Mail for the Historian Event
Microsoft Access wikipedia , lookup
Oracle Database wikipedia , lookup
Concurrency control wikipedia , lookup
Microsoft Jet Database Engine wikipedia , lookup
Database model wikipedia , lookup
Open Database Connectivity wikipedia , lookup
Relational model wikipedia , lookup
Microsoft SQL Server wikipedia , lookup
8/22/13 Configuring SQLMail or Database Mail for the Historian Event System Tech Note 551 Configuring SQLMail or Database Mail for the Historian Event System All Tech Notes, Tech Alerts and KBC D documents and software are provided "as is" without warranty of any kind. See the Terms of Use for more information. Topic#: 002298 C reated: September 2008 Updated: February 2009 Introduction This Tech Note provides procedures for configuring either SQLMail or Database Mail on SQL Server 2005. The InSQL Event System supports both. The examples are based on a Microsoft Exchange Server Mail account. Note: This Tech Note is intended to provide helpful suggestions, and its content is NOT supported by Wonderware. Wonderware is not responsible for Microsoft's SQL mail and Database Mail configuration. If any issues are encountered, please contact Microsoft Support. Application Versions IndustrialSQL Server Historian 9.0 and later Microsoft SQL Server 2005 Configuring SQLMail SQLMail is the legacy mailing system for Microsoft SQL Server. The command that is used to send mail by the IndustrialSQL Server Event System is xp_sendmail. SQL Server 2005 by default has disabled these commands so you must enable them. Note: You can copy/paste all the SQL statements included in this Tech Note from your browser. Enabling SQLMail To enable xp_sendmail, run the following SQL statement. use master go sp_configure 'show advanced options',1 go reconfigure with override go sp_configure 'SQL Mail XPs',1 go reconfigure go https://wdnresource.wonderware.com/support/kbcd/html/1/t002298.htm 1/9 8/22/13 Configuring SQLMail or Database Mail for the Historian Event System Configure a Default Mail Profile Now that you've enabled SQLMail, configure a default mail profile for the SQL Server Machine. 1. Go to Control Panel and select Mail. 2. Select Email Accounts. 3. Configure the Exchange Server Account that you will use to send email: F IGURE 1: C ONFIGURE E- MAIL ACCOUNT SETTINGS To send email using the Exchange Server account, you must have the SQLServer (MSSQLServer) service log in as the user that is used in the mail profile. 4. Go to Services and change the logon user for SQL Server (MSSQLServer). Note: If the authentication for the Exchange account is not a domain user, you must use DatabaseMail to perform Basic Authentication. https://wdnresource.wonderware.com/support/kbcd/html/1/t002298.htm 2/9 8/22/13 Configuring SQLMail or Database Mail for the Historian Event System F IGURE 2: C ONFIGURE THE LOG ON FOR MSSQLSERVER Test the SQLMail Configuration 1. Prior to configuring an event, test the SQLMail configuration by running the following command using SQL Server Management Studio: exec xp_startmail exec xp_sendmail @recipients="[email protected]", @subject="Email Test", @message = "This is a test" F IGURE 3: EXECUTE XP_STARTMAIL AND XP_SENDMAIL 2. If the test succeeds, you can configure an InSQL Event email from the Event System. https://wdnresource.wonderware.com/support/kbcd/html/1/t002298.htm 3/9 8/22/13 Configuring SQLMail or Database Mail for the Historian Event System F IGURE 4: C ONFIGURE AN EMAIL FROM THE INSQL EVENT SYSTEM Using DatabaseMail for Event System Emails Database Mail is the new mailing system for SQL Server. The command that sends mail by the InSQL Event System is xp_sendmail. The DatabaseMail stored procedure that sends email is sp_send_dbmail. The following steps describe how to use DatabaseMail with the InSQL Event System. Enabling Database Mail SQL Server 2005 by default has disabled these commands. To enable sp_send_dbmail, run the SQL statement below: use master go sp_configure 'show advanced options',1 go reconfigure with override go sp_configure 'Database Mail XPs',1 go reconfigure go Configuring Database Mail Configure Database Mail from SQL Server Management Studio. 1. Go to the Management section and double-click Database Mail. https://wdnresource.wonderware.com/support/kbcd/html/1/t002298.htm 4/9 8/22/13 Configuring SQLMail or Database Mail for the Historian Event System F IGURE 5: C ONFIGURE DATABASEMAIL 2. Select the Set up Database Mail option. https://wdnresource.wonderware.com/support/kbcd/html/1/t002298.htm 5/9 8/22/13 Configuring SQLMail or Database Mail for the Historian Event System F IGURE 6: SET UP DATABASE MAIL 3. Type a profile name (i.e. InSQLMail). You will need to remember this profile name as it will be used later. F IGURE 7: TYPE A PROFILE NAME 4. Click the Add button to add an SMTP account. 5. Type the necessary information for your exchange server account. https://wdnresource.wonderware.com/support/kbcd/html/1/t002298.htm 6/9 8/22/13 Configuring SQLMail or Database Mail for the Historian Event System 6. F IGURE 8: TYPE IN THE NECESSARY EMAIL ACCOUNT INFORMATION 7. Click Next to proceed to the Profile Security Section. 8. Select the Private Profiles tab and change the user name to NT Authority\SYSTEM. This is the user that will be allowed to execute sp_send_dbmail. By default, the InSQLEventSystem service runs under NT Authority\SYSTEM user. 9. Select the profile that this user will have access to. https://wdnresource.wonderware.com/support/kbcd/html/1/t002298.htm 7/9 8/22/13 Configuring SQLMail or Database Mail for the Historian Event System F IGURE 9: C HANGE USER NAME AND SELECT THE ACCOUNT PROFILE 10. Click Next twice, then Finish to complete the wizard. Test Your Database Mail Configuration 1. To begin testing the Database Mail configuration, from management studio, right-click Database Mail and click Send a Test E-Mail. F IGURE 10: SEND TEST DATABASE MAIL 2. View Database Mail Logs from the same panel to see if any errors occurred. This will be helpful in debugging any failures. F IGURE 11: DATABASE MAIL LOG 3. To send email using Database Mail from the InSQL Event System, create a new event in https://wdnresource.wonderware.com/support/kbcd/html/1/t002298.htm 8/9 8/22/13 Configuring SQLMail or Database Mail for the Historian Event System InSQL. 4. Instead of using an Email Action Type, use Generic SQL with the following query (in the Action Query field): EXEC msdb.dbo.sp_send_dbmail @profile_name="InSQLMail", @recipients="[email protected]", @subject="Database Mail Test", @body="This is a test" Note: You must restart the InSQLEventSystem Service after making any changes to your event tags. Changes to Generic SQL Statements will not take affect until the service is restarted. Click the following icon to view this file in .pdf format: C . Azer Tech Notes are published occasionally by Wonderware Technical Support. Publisher: Invensys Systems, Inc., 26561 Rancho Parkway South, Lake Forest, C A 92630. There is also technical information on our software products at Wonderware Technical Support. For technical support questions, send an e-mail to [email protected]. Back to top ©2013 Invensys Systems, Inc. All rights reserved. No part of the material protected by this copyright may be reproduced or utilized in any form or by any means, electronic or mechanical, including photocopying, recording, broadcasting, or by anyinformation storage and retrieval system, without permission in writing from Invensys Systems, Inc. Terms of Use. https://wdnresource.wonderware.com/support/kbcd/html/1/t002298.htm 9/9