Custom Search
Logiclabz
  • Home
  • C#
  • Send E-Mail with Friendly Display Name in .Net 1.0 (System.Web.Mail)

Send E-Mail with Friendly Display Name in .Net 1.0 (System.Web.Mail)

The System.Web.Mail .NET namespace contains classes that used you to send email messages .NET applications using the CDOSYS (Collaboration Data Objects for Windows 2000) message component. The mail message is delivered through the SMTP mail service on an arbitrary SMTP server.

MailMessage provides properties and methods for constructing an e-mail message.
SmtpMail provides properties and methods for sending messages using the Collaboration Data Objects for Windows 2000 (CDOSYS) message component.
MailFormat provides enumerated values for e-mail format.
System.Web.Mail class and their enumeration is Obsolete with System.Net.Mail in Net2.0 Framework.

    try
    {
        //Creating new mail message
        System.Web.Mail.MailMessage MyMail = new System.Web.Mail.MailMessage();

        //Display Name can be sent using following format
        //\<<Friendly Display Name>>\ <mailaddress>"
        MyMail.From = @"\Webtips Emailer\ <admin@webtips.co.in>";

        //To Address
        MyMail.To = "webtips.co.in@gmail.com";

        // BCC Address
        MyMail.Bcc = "somename@someserver.com";

        //Mail Subject
        MyMail.Subject = "Subject Of the mail";

        //Body of the mail
        MyMail.Body = "<html><body>test mail message</body></html>";
        MyMail.BodyFormat = System.Web.Mail.MailFormat.Html;
        
        //SMTP Server name or IP from which mail to be sent
        System.Web.Mail.SmtpMail.SmtpServer = "smtp.someserver.com";

        //Sending Mail
        System.Web.Mail.SmtpMail.Send(MyMail);
    }
    catch
    {
    }



Leave a reply


Do you like this post?