public static
bool SendMailMessage(string SMTPServer,
string fromAddress,
string fromName,
string toAddress,
string toName,
string msgSubject,
string msgBody,
bool IsBodyHtml)
{
// Use the new v2.0 mail class to send an E-mail.
try
{
SmtpClient
client = new
SmtpClient(SMTPServer);
MailAddress
from = new
MailAddress(fromAddress,
fromName);
MailAddress
to = new
MailAddress(toAddress,
toName);
MailMessage
message = new
MailMessage(from, to);
message.Subject = msgSubject;
message.IsBodyHtml = IsBodyHtml;
message.Body = msgBody;
client.Send(message);
}
catch (System.Net.Mail.SmtpException)
{
throw;
}
catch (Exception)
{
throw;
}
return true;
}
SendMailMessage("localhost", "from@yourdomain.dk", "FromName", "to@yourdomain.dk", "ToName", "Mail emne",
"Mail tekst som kan indeholde <b>HTML</b> tegn!",
true);