Keyvan Nayyeri

God breathing through me

Gopi - SMTP Component for .NET 2.0

I share another component for .NET 2.0: Gopi (Gopi is the name of one of our old cats).

Gopi is a SMTP component for .NET 2.0.  I’ve written it based on .NET 2.0 new features in C#.  Probably you know that ASP.NET 2.0 has default features to configure your SMTP server for credentials but still you have to write your own storage system.  Gopi does this for you.

Gopi uses a SQL provider to save all emails in database and sends them from database when you want.  Gopi has a base provider for storage system and you can implement base class.  I didn't implement .NET 2.0 provider base class because it wasn't necessary in my mind. This is Gopi's simple structure:

Gopi Structure

.NET has left previous objects for emails and SMTP servers and they are obsolete now.  If you want to know how you should send emails via SMTP servers with credentials in a nutshell, take a look at this part of my code:

private bool SendMail(MailMessage Email)

{

    try

    {

        SmtpClient objSmtp = new SmtpClient(this._SMTPServer);

 

        objSmtp.DeliveryMethod = SmtpDeliveryMethod.Network;

 

        if (this._Username != null && this._Password != null)

        {

            NetworkCredential objCredential = new NetworkCredential(this._Username, this._Password);

            objSmtp.UseDefaultCredentials = false;

            objSmtp.Credentials = objCredential;

        }

 

        if (this._Port != -1)

            objSmtp.Port = this._Port;

 

        if (this._TimeOut != -1)

            objSmtp.Timeout = this._TimeOut;

 

        objSmtp.Send(Email);

 

        return true;

    }// try

    catch

    {

        return false;

    }// catch

}// SendMail

Gopi is available with full source code and SQL script (Table and Stored Procedures) here.

Sidenote: I’ll be happy, if you develop my components and Add-ons and let me know your ideas and suggestions.  If you modified my components and codes, it’s worth to share it with me and others.  I’ll publish any modifications to my codes on my file gallery.

2 Comments

Keyvan Nayyeri
Sep 01, 2006 11:15 AM
#
Any web application needs a way to send emails to different kinds of its users. This capability is provided

chewytest2
Dec 24, 2006 4:21 AM
#
Any web application needs a way to send emails to different kinds of its users. This capability is provided

Leave a Comment





Ads Powered by Lake Quincy Media Network