Files
mono/mcs/class/System.Web/System.Web.Mail/SmtpMail.cs
T
Per Arneng b2c2697cf8 SmtpServer now defaults to localhost
svn path=/trunk/mcs/; revision=11989
2003-02-26 05:57:18 +00:00

74 lines
1.4 KiB
C#

//
// System.Web.Mail.SmtpMail.cs
//
// Author:
// Lawrence Pit ([email protected])
// Per Arneng ([email protected]) (SmtpMail.Send)
//
using System;
using System.Net;
using System.IO;
using System.Reflection;
namespace System.Web.Mail
{
/// <remarks>
/// </remarks>
public class SmtpMail
{
private static string smtpServer = "localhost";
// Constructor
private SmtpMail ()
{
/* empty */
}
// Properties
public static string SmtpServer {
get { return smtpServer; }
set { smtpServer = value; }
}
public static void Send (MailMessage message)
{
try {
SmtpClient smtp = new SmtpClient (smtpServer);
smtp.Send (message);
smtp.Close ();
} catch (SmtpException ex) {
// LAMESPEC:
// .NET sdk throws HttpException
// for some reason so to be compatible
// we have to do it to :(
throw new HttpException (ex.Message);
} catch (IOException ex) {
throw new HttpException (ex.Message);
}
}
public static void Send (string from, string to, string subject, string messageText)
{
MailMessage message = new MailMessage ();
message.From = from;
message.To = to;
message.Subject = subject;
message.Body = messageText;
Send (message);
}
}
} //namespace System.Web.Mail