Click here to Skip to main content
Click here to Skip to main content

Sending complex emails in .NET 1.1

By , 15 Mar 2006
 
email_sending_in_c__src.zip
SampleSendMail
App.ico
bin
SampleSendMail.csproj.user
Utils
bin
Utils.csproj.user
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using Utils;
using System.Web.Mail;

namespace SampleSendMail
{
	/// <summary>
	/// Summary description for SampleForm.
	/// </summary>
	public class SampleForm : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Button button2;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public SampleForm()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new SampleForm());
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.button1 = new System.Windows.Forms.Button();
			this.button2 = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(72, 80);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(128, 23);
			this.button1.TabIndex = 0;
			this.button1.Text = "Send Sample Email";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(216, 80);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(224, 23);
			this.button2.TabIndex = 1;
			this.button2.Text = "Send Sample Email with Authentication";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// SampleForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(552, 182);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.button1);
			this.Name = "SampleForm";
			this.Text = "SampleForm";
			this.ResumeLayout(false);

		}
		#endregion

		private void button1_Click(object sender, System.EventArgs e)
		{
			EnhancedMailMessage.QuickSend("smtp.server.com", 
				"to.email@domain.com", 
				"from.email@domain.com",
				"Subject",
				"Body",
				MailFormat.Html);
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			EnhancedMailMessage msg = new EnhancedMailMessage();

			msg.From = "your.address@gmail.com";
			msg.FromName = "Your name";
			msg.To = "to.email@domain.com";
			msg.Subject = "Test email from gmail";
			msg.Body = "Gmail is great";

			msg.SMTPServerName = "smtp.gmail.com";
			msg.SMTPUserName = "your.address@gmail.com";
			msg.SMTPUserPassword = "yourpassword";
			msg.SMTPServerPort = 465;
			msg.SMTPSSL = true;

			msg.Send();
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of use 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 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

About the Author

Florentin BADEA
Web Developer
Romania Romania
Member
I am a software developer from Bucharest, Romania. I am the founder of Outside Software Inc., a software company that offers outsourcing services to partners all over the world.

If you want to help me improve the quality of my articles, Click here to take a survey now. Create your own online surveys using eSurveysPro.

Outside Software Inc. recently launched v1.6 of our charting control. If you need ASP.NET Charts or Windows Forms .NET Charts, then ChartingControl.NET is for you.

Other products: html to pdf converter. If you need a library that can convert from html to pdf, then ExpertPDF HtmlToPdf Converter is for you.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 16 Mar 2006
Article Copyright 2006 by Florentin BADEA
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid