Posted by: jwalin on: May 15, 2008
1. Install a mail exchange client on server, Outlook is good.
2. Open Control Panel->Mail->Show Profiles, add a domain profile.
3. Open Microsoft SQL Server 2005->Configuration Tools->SQL Server Configuration Manager->SQL Server 2005 Services, double-click the instance, fill your domain account and save the change, restart the instance.
4. Open Microsoft SQL Server 2005-> SQL Server Management Studio-> Legacy-> SQL Mail , choose the profile, save the change.
5. To test SQL Mail, you may execute xp_sendmail like this:
exec master.dbo.xp_sendmail
@recipients = N’XXX@XXX.com’,
@subject = N’Subject Here’,
@message = N’Message Here’
6. You may get the status of the SQL Server service like this:
using System.ServiceProcess;
string myServiceName = “MSSQL$SQLEXPRESS”; //service name of SQL Server Express
ServiceController mySC = new ServiceController(yourServiceName);
if(mySC.Status.Equals(ServiceControllerStatus.Stopped))
{
//….
}else if(mySC.Status.Equals(ServiceControllerStatus.StopPending))
{
//…
}
else
{
//…
}
Then you can send the status in a mail.
For more information, you can refer to the following documents
http://msdn.microsoft.com/en-us/library/8b83ac7t(VS.80).aspx http://support.microsoft.com/kb/912426/en-us/