65.9K
CodeProject is changing. Read more.
Home

SMTP Mailer with Authentication

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.10/5 (10 votes)

Oct 26, 2003

1 min read

viewsIcon

106935

downloadIcon

2472

.NET assembly, 100% managed code. Send mails using a SMTP server that requires authentication.

Introduction

This article describes a simple assembly to send mails programmatically using a SMTP server that requires authentication. It also works with those servers that doesn't require it.

In this release, you cannot use attachments, but I will implement it as soon as possible.

To show you how simple this component is, I'll show you it's main interface:

The main method is SendMail:

1st Overload

Used for sending a simple mail using a server without authentication. The default MailFormat is HTML.

public System.Boolean SendMail ( System.String from , System.String to , System.String subject , System.String message , System.String serverName )

2nd Overload

Used for sending a simple mail using a server with authentication. The default MailFormat is HTML.

public System.Boolean SendMail ( System.String from , System.String to , System.String subject , System.String message , System.String AUTH_Name , System.String AUTH_Password , System.String serverName )

3rd Overload

Used for sending a mail using a server with authentication. Here you can specify the MailFormat and also the server port.

public System.Boolean SendMail ( System.String from , System.String to , System.String subject , System.String message , MailFormat format , System.String AUTH_Name , System.String AUTH_Password , System.String serverName , System.Int32 port )

When the method SendMail returns false, you have an Err property that contains the Exception that originated the failure of the method call.