Sending E-mail using SMTP Service


"Email" term is one of the most practical words in IT field. There are some classes in .Net which help us construct and build mail messages.

In this application I have used SMTP (Simple Mail Transfer Protocol) service to send messages.

As you see (in figure 1) "E-mail Console" provides some of standard email fields which is familiar for most of you.

Figure 1(Email Console main form)

With this application you can send message to any number of recipients which are delimited by ";" character. For example you can fill the "To address" field like this:

"[email protected];[email protected];[email protected]"

Moreover, if any mistake happens in one or more addresses, those addresses will be recorded and will be shown in a list box before sending operation performed.

Actually email addresses are evaluating with a function named "valid_email"which gets an email address and validates it.  Remember that only "_" and "." Characters accepted in addresses.

Finally, I like to focus on "smtpclient" class which exists in "System.Net.Mail" namespace. "smtpclient" class needs some properties be set, based on the application.

In this application I preferred to set the

  • "smtpclient.DeliveryMethod" - Specifies how outgoing email messages will be handled.
  • "SmtpDeliveryMethod.PickupDirectoryFromIis" - which sends message using IIS's Queue.

For, any additional information the source code will be useful. I would also be happy to receive the feedbacks.

Up Next
    Ebook Download
    View all
    Learn
    View all