Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 85,977 times

Contents

Related Categories

Custom SMTP in C# - Demonstration

randy

Demonstration

To send an SMTP message, you simply instantiate an instance of the class, set the appropriate data members and call the Send method.

static void Main( string[] args)
{
    try
    {
        kbcafe.Smtp smtp = new kbcafe.Smtp();
        smtp.server = "smtp.xxx.com";
        smtp.from = "yyy@xxx.com (zzz)";
        smtp.subject = "Hello World";
        smtp.bodyHtml = "<HTML><BODY>Hello World</BODY></HTML>";
        smtp.to.Add("yyy@xxx.com");
        smtp.Send();
    }
    catch( kbcafe.SmtpException e)
    {
        System.Console.WriteLine("{ 0}", e.What());
    }
}

If you reuse this code, replace the xxx, yyy and zzz parameters by valid values. A valid from address may be "someone@somewhere.com (Joe Bloggs)".

Randy's article are Copyright 1998-2003 Randy Charles Morin

Comments

  • receiving emails

    Posted by lesnikowski on 10 Nov 2005

    [url="http://www.lesnikowski.com/mail"]http://www.lesnikowski.com/mail[/url]

  • receiving emails

    Posted by lesnikowski on 10 Nov 2005

    Try using this library:
    [url="http://www.lesnikowski.com/mail"]http://www.lesnikowski.com/mail[/url]

    It's simple and effective.
    Allows sending, receiving and parsing email messages.
    Encodes/dec...

  • Posted by Michael H on 01 Sep 2004

    well... TO is used for the main person you're sending to.

    CC (and BCC, but the B stands for "Blind" so it's not marked as a copy) are traditionally used to send
    it to others that need to see the l...

  • Posted by arfong on 01 Sep 2004

    I want to ask the same question as well.

  • Posted by Wynand on 14 May 2004

    Yes, but what if you want to code a filter application? Then you need to RECEIVE SMTP BEFORE sending it to SMTP and then POP3 servers.

    So to RECEIVE SMTP or INTERCEPT SMTP packets, does one need to...