Send HTML Mail
using System;
using System.Configuration;
using System.Web;
using System.IO;
using System.Net.Mail;
using System.Collections.Generic;
using System.Text;
public class Mail
{
/// <returns></returns>
public static bool sendTXTMail(string from, string to, string subject, string body)
{
try
{
SmtpClient mailClient = new SmtpClient(Tg.SMTPHost, 25);
MailMessage thisMailMessage = new MailMessage(from, to, subject, body);
thisMailMessage.IsBodyHtml = false;
mailClient.EnableSsl = false;
mailClient.UseDefaultCredentials = true;
mailClient.DeliveryMethod = SmtpDeliveryMethod.Network;
mailClient.Send(thisMailMessage);
}
catch
{
return false;
}
return true;
}
public static bool sendHTMLMail(string from, string to, string subject, string body)
{
try
{
SmtpClient mailClient = new SmtpClient(Tg.SMTPHost, 25);
MailMessage thisMailMessage = new MailMessage(from, to, subject, body);
thisMailMessage.IsBodyHtml = true;
mailClient.EnableSsl = false;
mailClient.UseDefaultCredentials = true;
mailClient.DeliveryMethod = SmtpDeliveryMethod.Network;
mailClient.Send(thisMailMessage);
}
catch
{
return false;
}
return true;
}
}
Related examples in the same category