|
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 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.