Send HTML Mail : Mail « Network « C# / C Sharp






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

1.SmtpClient: From, Subject, Body, Attachments, To
2.Mail Test
3.A POP3 e-mail checkerA POP3 e-mail checker
4.Fancy Mail Test
5.Mail Attach Test
6.Send Email
7.Is Valid Email
8.Is Valid Email Address
9.Is Email
10.Sends a MailMessage object using the SMTP settings.
11.Smtp Send