Click here to Skip to main content
15,889,595 members
Articles / Programming Languages / C#
Article

EmailSender

Rate me:
Please Sign up or sign in to vote.
2.69/5 (16 votes)
17 Feb 20031 min read 91.6K   3.4K   57   7
A suite of classes to send email messages and attachments.

EMailSender - a png file

Address Book - a png file

Introduction

EmailSender is a simple application which allows you to send an email with a text body or an HTML body and if you want one attachment file. The control which displays the email body is only a RichText control. This project is a mix of two initial projects:

  1. EmailSender C# project without an address book.
  2. AddressBook C# project.

Important note: You need the MagicLibrary to build the menus and the TabControl.

Description

This project uses some useful namespaces:

  • System.Windows.Forms and MagicLibrary classes to build the user interface (controls, context menus, notify icon, ...).
  • System.IO to read and write XML files.
  • System.Xml to parse XML files.
  • System.Web.Mail to create and send the email.

Also, EmailSender uses two XML files:

1. EMailConfig.xml to configure the email address and the smtpserver . You must edit and configure this file before start the application.

XML
<?xml version="1.0" encoding="utf-8" ?>
<providers>
  <name>
    Provider name // examples: CompuServe, American Online ...,
    do nothing but it's a better description
    <smtpserver>smtpserver // examples: smtp.providerName.com,
    mail.providerName.com or the ip address</smtpserver>
    <email>your email address for this provider</email>
 </name>
    // You can add an another provider
 <name>
    <smtpserver></smtpserver>
    <email></email>
 </name>
</providers>

When you connect to the net, choose the right email for the current provider (smtpserver will be right). If you change the provider, you must also change the email. With this, you don't need authenticate (no username and no password) to connect to the SMTP server.

2. AddressBook.xml with only two contacts but you can add or remove friends and contacts.

XML
<?xml version="1.0" encoding="utf-8" ?>
<book>
  <friend>
     <name>name friend</name>
     <email>email friend</email>
  </friend>
  <contact>
     <description>Submit an article to CodeProject</description>
     <email>submit@codeproject.com</email>
  </contact>
  <friend>
     <name>t</name>
     <email></email>
  </friend>
  <contact>
     <description>Contact the CodeProject webmaster</description>
     <email>webmaster@codeproject.com</email>
  </contact>
</book>

Check the item in the ListView for select or remove.

Important note: the files EmailConfig.xml and AdressBook.xml must reside in the application directory (bin/debug, bin/release for examples).

That's all folks and good luck with C# programming .

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
France France
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionExample or add for control ... ? Pin
M i s t e r L i s t e r20-Nov-03 15:13
M i s t e r L i s t e r20-Nov-03 15:13 
AnswerRe: Example or add for control ... ? Pin
pat2920-Nov-03 18:01
pat2920-Nov-03 18:01 
GeneralRe: Example or add for control ... ? Pin
M i s t e r L i s t e r20-Nov-03 18:20
M i s t e r L i s t e r20-Nov-03 18:20 
GeneralRe: Example or add for control ... ? Pin
pat2921-Nov-03 9:44
pat2921-Nov-03 9:44 
GeneralWrong URL for MagicLibrary Pin
AxelM18-Feb-03 20:44
AxelM18-Feb-03 20:44 
GeneralRe: Wrong URL for MagicLibrary Pin
leppie19-Feb-03 6:34
leppie19-Feb-03 6:34 
GeneralRe: Wrong URL for MagicLibrary Pin
AxelM19-Feb-03 20:57
AxelM19-Feb-03 20:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.