Click here to Skip to main content
15,894,106 members
Articles / Programming Languages / C#

.NET Mail Composer

Rate me:
Please Sign up or sign in to vote.
4.94/5 (39 votes)
6 Aug 2008CPOL2 min read 55.6K   5.2K   60  
Compose mail messages and send them through your mail account provider.
using System;
using System.Windows.Forms;

namespace MailComposer
{
    static class Program
    {
        public static string UserId = "", Password = "", Host = "";
        public static string ReplyTo = "", DisplayName = "";
        public static string EmailLocation = "";
        public static int ProviderIndex;
        public static int Port = 587;
        public static ListBox Recipients;
        public static ListView Attachments;
        public static bool SecureConnection;

        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Recipients = new ListBox();
            Attachments = new ListView();
            Application.Run(new frmComposer());
        }

        public static bool ValidateEmail(string Email)
        {
            if ((Email.IndexOf('@') != Email.LastIndexOf('@')) || Email.IndexOf('@') == -1) return false;

            if (Email[Email.IndexOf('@') + 1] == '.') return false;

            if ((Email.LastIndexOf(".") == Email.Length - 1) || Email.LastIndexOf(".") == -1) return false;

            if (Email.Contains(" ") || Email.Contains("\\") || Email.Contains("/") || Email.Contains("*") || Email.Contains(";")) return false;

            return true;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
India India


Completed B.Com(CS) at DGVC and GNIIT Software Engineering at NIIT. Resident at Chennai and working as a Software Engineer.



 Language / Technology :

C#, ADO.NET, ASP.NET, MVC, WCF, ASP, PHP, XML, Java, J2EE, HTML, JavaScript, JQuery, AngularJS, VB Script, C++, MS SQL Server, SSRS, MySql, Oracle, Oracle Forms Development, Windows, Linux.



Click here to view other articles.


Mail Me at:  shridhar_tl@ymail.com


Visit my Site:  www.iCodeIt.in


Comments and Discussions