using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.IO;
using System.Windows.Forms;
using System.Data;
using BooProd.BMail;
using AxSHDocVw;
namespace BooProd.BMail.Tester
{
/// <summary>
/// Application for testing the BooProd.BMail assemby.
///
/// 2005-01-01 / CB => First Version
/// </summary>
public class MainForm : System.Windows.Forms.Form
{
private System.Windows.Forms.Button buttonSend;
private AxSHDocVw.AxWebBrowser axWebBrowser;
private System.Windows.Forms.Button buttonPreview;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBoxHTMLFileName;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.ComboBox comboBoxHTMLTagReplacement;
private System.Windows.Forms.GroupBox groupBox;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox textBoxFrom;
private System.Windows.Forms.TextBox textBoxTo;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox textBoxSubject;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox textBoxBcc;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.TextBox textBoxCc;
private System.Windows.Forms.CheckBox checkBoxNotify;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.TextBox textBoxSMTPServer;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.TextBox textBoxSMTPLogin;
private System.Windows.Forms.TextBox textBoxSMTPPassword;
private System.Windows.Forms.CheckBox checkBoxUseSMTPServer;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.TextBox textBoxAttachement;
private System.Windows.Forms.Button buttonChooseFile;
private System.Windows.Forms.OpenFileDialog openFileDialog;
/// <summary>
/// Variable n�cessaire au concepteur.
/// </summary>
private System.ComponentModel.Container components = null;
public MainForm()
{
//
// Requis pour la prise en charge du Concepteur Windows Forms
//
InitializeComponent();
// 1) Generate default HTML preview
string vEMailTemplateFile= "EMailTemplate.html";
string vCurrentDir= Directory.GetCurrentDirectory();
string vFileName= Path.Combine(vCurrentDir, vEMailTemplateFile);
this.textBoxHTMLFileName.Text= vFileName;
object o= null;
this.axWebBrowser.Navigate(this.textBoxHTMLFileName.Text,ref o,ref o,ref o,ref o);
// 2) Set the default HTML BMailId Tag replacement method
this.comboBoxHTMLTagReplacement.SelectedIndex= 0;
}
/// <summary>
/// Nettoyage des ressources utilis�es.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Code g�n�r� par le Concepteur Windows Form
/// <summary>
/// M�thode requise pour la prise en charge du concepteur - ne modifiez pas
/// le contenu de cette m�thode avec l'�diteur de code.
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MainForm));
this.buttonSend = new System.Windows.Forms.Button();
this.axWebBrowser = new AxSHDocVw.AxWebBrowser();
this.buttonPreview = new System.Windows.Forms.Button();
this.textBoxHTMLFileName = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.comboBoxHTMLTagReplacement = new System.Windows.Forms.ComboBox();
this.groupBox = new System.Windows.Forms.GroupBox();
this.textBoxTo = new System.Windows.Forms.TextBox();
this.textBoxFrom = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label5 = new System.Windows.Forms.Label();
this.textBoxSubject = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.textBoxBcc = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.textBoxCc = new System.Windows.Forms.TextBox();
this.checkBoxNotify = new System.Windows.Forms.CheckBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.label8 = new System.Windows.Forms.Label();
this.textBoxSMTPServer = new System.Windows.Forms.TextBox();
this.label9 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.textBoxSMTPLogin = new System.Windows.Forms.TextBox();
this.textBoxSMTPPassword = new System.Windows.Forms.TextBox();
this.checkBoxUseSMTPServer = new System.Windows.Forms.CheckBox();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.label11 = new System.Windows.Forms.Label();
this.textBoxAttachement = new System.Windows.Forms.TextBox();
this.buttonChooseFile = new System.Windows.Forms.Button();
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
((System.ComponentModel.ISupportInitialize)(this.axWebBrowser)).BeginInit();
this.groupBox.SuspendLayout();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox4.SuspendLayout();
this.SuspendLayout();
//
// buttonSend
//
this.buttonSend.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonSend.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.buttonSend.Location = new System.Drawing.Point(88, 24);
this.buttonSend.Name = "buttonSend";
this.buttonSend.Size = new System.Drawing.Size(112, 24);
this.buttonSend.TabIndex = 14;
this.buttonSend.Text = "Send the EMail";
this.buttonSend.Click += new System.EventHandler(this.buttonSend_Click);
//
// axWebBrowser
//
this.axWebBrowser.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.axWebBrowser.ContainingControl = this;
this.axWebBrowser.Enabled = true;
this.axWebBrowser.Location = new System.Drawing.Point(8, 72);
this.axWebBrowser.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axWebBrowser.OcxState")));
this.axWebBrowser.Size = new System.Drawing.Size(432, 192);
this.axWebBrowser.TabIndex = 9;
//
// buttonPreview
//
this.buttonPreview.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonPreview.Location = new System.Drawing.Point(8, 24);
this.buttonPreview.Name = "buttonPreview";
this.buttonPreview.Size = new System.Drawing.Size(72, 24);
this.buttonPreview.TabIndex = 13;
this.buttonPreview.Text = "Preview";
this.buttonPreview.Click += new System.EventHandler(this.buttonPreview_Click);
//
// textBoxHTMLFileName
//
this.textBoxHTMLFileName.Location = new System.Drawing.Point(8, 40);
this.textBoxHTMLFileName.Name = "textBoxHTMLFileName";
this.textBoxHTMLFileName.ReadOnly = true;
this.textBoxHTMLFileName.Size = new System.Drawing.Size(256, 20);
this.textBoxHTMLFileName.TabIndex = 12;
this.textBoxHTMLFileName.Text = "-";
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(280, 16);
this.label1.TabIndex = 11;
this.label1.Text = "HTML EMail Template, with embeded BMailId Tags:";
//
// label2
//
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label2.Location = new System.Drawing.Point(272, 24);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(176, 16);
this.label2.TabIndex = 13;
this.label2.Text = "BMailId replacement method:";
//
// comboBoxHTMLTagReplacement
//
this.comboBoxHTMLTagReplacement.DisplayMember = "3 - Use BMailIdList object";
this.comboBoxHTMLTagReplacement.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxHTMLTagReplacement.Items.AddRange(new object[] {
"1 - Use only Id and Value",
"2 - Use BMailId object",
"3 - Use BMailIdList object"});
this.comboBoxHTMLTagReplacement.Location = new System.Drawing.Point(272, 40);
this.comboBoxHTMLTagReplacement.Name = "comboBoxHTMLTagReplacement";
this.comboBoxHTMLTagReplacement.Size = new System.Drawing.Size(168, 21);
this.comboBoxHTMLTagReplacement.TabIndex = 7;
//
// groupBox
//
this.groupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(192)), ((System.Byte)(192)));
this.groupBox.Controls.Add(this.buttonPreview);
this.groupBox.Controls.Add(this.buttonSend);
this.groupBox.Location = new System.Drawing.Point(248, 472);
this.groupBox.Name = "groupBox";
this.groupBox.Size = new System.Drawing.Size(208, 56);
this.groupBox.TabIndex = 15;
this.groupBox.TabStop = false;
this.groupBox.Text = "5) Send";
//
// textBoxTo
//
this.textBoxTo.Location = new System.Drawing.Point(160, 32);
this.textBoxTo.Name = "textBoxTo";
this.textBoxTo.Size = new System.Drawing.Size(144, 20);
this.textBoxTo.TabIndex = 3;
this.textBoxTo.Text = "myFriend@yy.com";
//
// textBoxFrom
//
this.textBoxFrom.Location = new System.Drawing.Point(8, 32);
this.textBoxFrom.Name = "textBoxFrom";
this.textBoxFrom.Size = new System.Drawing.Size(144, 20);
this.textBoxFrom.TabIndex = 1;
this.textBoxFrom.Text = "myEMail@xx.com";
//
// label4
//
this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label4.Location = new System.Drawing.Point(160, 16);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(100, 16);
this.label4.TabIndex = 16;
this.label4.Text = "To:";
//
// label3
//
this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label3.Location = new System.Drawing.Point(8, 16);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(32, 16);
this.label3.TabIndex = 15;
this.label3.Text = "From:";
//
// groupBox1
//
this.groupBox1.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(192)));
this.groupBox1.Controls.Add(this.checkBoxNotify);
this.groupBox1.Controls.Add(this.textBoxCc);
this.groupBox1.Controls.Add(this.label7);
this.groupBox1.Controls.Add(this.textBoxBcc);
this.groupBox1.Controls.Add(this.label6);
this.groupBox1.Controls.Add(this.textBoxSubject);
this.groupBox1.Controls.Add(this.label5);
this.groupBox1.Controls.Add(this.textBoxFrom);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.textBoxTo);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Location = new System.Drawing.Point(8, 8);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(448, 105);
this.groupBox1.TabIndex = 16;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "1) Header";
//
// label5
//
this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label5.Location = new System.Drawing.Point(8, 56);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(100, 16);
this.label5.TabIndex = 19;
this.label5.Text = "Subject:";
//
// textBoxSubject
//
this.textBoxSubject.Location = new System.Drawing.Point(8, 72);
this.textBoxSubject.Name = "textBoxSubject";
this.textBoxSubject.Size = new System.Drawing.Size(296, 20);
this.textBoxSubject.TabIndex = 6;
this.textBoxSubject.Text = "About the new year ...";
//
// label6
//
this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label6.Location = new System.Drawing.Point(312, 56);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(100, 16);
this.label6.TabIndex = 21;
this.label6.Text = "Bcc:";
//
// textBoxBcc
//
this.textBoxBcc.Location = new System.Drawing.Point(312, 72);
this.textBoxBcc.Name = "textBoxBcc";
this.textBoxBcc.Size = new System.Drawing.Size(128, 20);
this.textBoxBcc.TabIndex = 5;
this.textBoxBcc.Text = "";
//
// label7
//
this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label7.Location = new System.Drawing.Point(312, 16);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(100, 16);
this.label7.TabIndex = 23;
this.label7.Text = "Cc:";
//
// textBoxCc
//
this.textBoxCc.Location = new System.Drawing.Point(312, 32);
this.textBoxCc.Name = "textBoxCc";
this.textBoxCc.Size = new System.Drawing.Size(128, 20);
this.textBoxCc.TabIndex = 4;
this.textBoxCc.Text = "";
//
// checkBoxNotify
//
this.checkBoxNotify.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.checkBoxNotify.Location = new System.Drawing.Point(96, 16);
this.checkBoxNotify.Name = "checkBoxNotify";
this.checkBoxNotify.Size = new System.Drawing.Size(56, 16);
this.checkBoxNotify.TabIndex = 2;
this.checkBoxNotify.Text = "Notify";
//
// groupBox2
//
this.groupBox2.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(255)), ((System.Byte)(255)));
this.groupBox2.Controls.Add(this.axWebBrowser);
this.groupBox2.Controls.Add(this.comboBoxHTMLTagReplacement);
this.groupBox2.Controls.Add(this.label2);
this.groupBox2.Controls.Add(this.textBoxHTMLFileName);
this.groupBox2.Controls.Add(this.label1);
this.groupBox2.Location = new System.Drawing.Point(8, 120);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(448, 272);
this.groupBox2.TabIndex = 17;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "2) Body";
//
// groupBox3
//
this.groupBox3.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(255)), ((System.Byte)(192)));
this.groupBox3.Controls.Add(this.checkBoxUseSMTPServer);
this.groupBox3.Controls.Add(this.textBoxSMTPPassword);
this.groupBox3.Controls.Add(this.textBoxSMTPLogin);
this.groupBox3.Controls.Add(this.label10);
this.groupBox3.Controls.Add(this.label9);
this.groupBox3.Controls.Add(this.textBoxSMTPServer);
this.groupBox3.Controls.Add(this.label8);
this.groupBox3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.groupBox3.Location = new System.Drawing.Point(8, 400);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(232, 128);
this.groupBox3.TabIndex = 18;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "3) SMTP Account";
//
// label8
//
this.label8.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label8.Location = new System.Drawing.Point(8, 16);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(100, 24);
this.label8.TabIndex = 0;
this.label8.Text = "Server:";
//
// textBoxSMTPServer
//
this.textBoxSMTPServer.Enabled = false;
this.textBoxSMTPServer.Location = new System.Drawing.Point(8, 32);
this.textBoxSMTPServer.Name = "textBoxSMTPServer";
this.textBoxSMTPServer.Size = new System.Drawing.Size(208, 20);
this.textBoxSMTPServer.TabIndex = 8;
this.textBoxSMTPServer.Text = "smtp.domain.com";
//
// label9
//
this.label9.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label9.Location = new System.Drawing.Point(8, 56);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(100, 24);
this.label9.TabIndex = 2;
this.label9.Text = "Login:";
//
// label10
//
this.label10.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label10.Location = new System.Drawing.Point(120, 56);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(100, 24);
this.label10.TabIndex = 3;
this.label10.Text = "Password";
//
// textBoxSMTPLogin
//
this.textBoxSMTPLogin.Enabled = false;
this.textBoxSMTPLogin.Location = new System.Drawing.Point(8, 72);
this.textBoxSMTPLogin.Name = "textBoxSMTPLogin";
this.textBoxSMTPLogin.Size = new System.Drawing.Size(104, 20);
this.textBoxSMTPLogin.TabIndex = 9;
this.textBoxSMTPLogin.Text = "login";
//
// textBoxSMTPPassword
//
this.textBoxSMTPPassword.Enabled = false;
this.textBoxSMTPPassword.Location = new System.Drawing.Point(120, 72);
this.textBoxSMTPPassword.Name = "textBoxSMTPPassword";
this.textBoxSMTPPassword.PasswordChar = '*';
this.textBoxSMTPPassword.Size = new System.Drawing.Size(96, 20);
this.textBoxSMTPPassword.TabIndex = 10;
this.textBoxSMTPPassword.Text = "Password";
//
// checkBoxUseSMTPServer
//
this.checkBoxUseSMTPServer.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.checkBoxUseSMTPServer.Location = new System.Drawing.Point(48, 104);
this.checkBoxUseSMTPServer.Name = "checkBoxUseSMTPServer";
this.checkBoxUseSMTPServer.Size = new System.Drawing.Size(144, 16);
this.checkBoxUseSMTPServer.TabIndex = 11;
this.checkBoxUseSMTPServer.Text = "Use this SMTP server";
this.checkBoxUseSMTPServer.CheckedChanged += new System.EventHandler(this.checkBoxUseSMTPServer_CheckedChanged);
//
// groupBox4
//
this.groupBox4.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(192)), ((System.Byte)(255)));
this.groupBox4.Controls.Add(this.buttonChooseFile);
this.groupBox4.Controls.Add(this.textBoxAttachement);
this.groupBox4.Controls.Add(this.label11);
this.groupBox4.Location = new System.Drawing.Point(248, 400);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(208, 64);
this.groupBox4.TabIndex = 19;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "4) Attachement";
//
// label11
//
this.label11.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label11.Location = new System.Drawing.Point(8, 16);
this.label11.Name = "label11";
this.label11.TabIndex = 0;
this.label11.Text = "Attachement:";
//
// textBoxAttachement
//
this.textBoxAttachement.Location = new System.Drawing.Point(8, 32);
this.textBoxAttachement.Name = "textBoxAttachement";
this.textBoxAttachement.ReadOnly = true;
this.textBoxAttachement.Size = new System.Drawing.Size(160, 20);
this.textBoxAttachement.TabIndex = 1;
this.textBoxAttachement.Text = "";
//
// buttonChooseFile
//
this.buttonChooseFile.Location = new System.Drawing.Point(176, 32);
this.buttonChooseFile.Name = "buttonChooseFile";
this.buttonChooseFile.Size = new System.Drawing.Size(24, 23);
this.buttonChooseFile.TabIndex = 12;
this.buttonChooseFile.Text = "...";
this.buttonChooseFile.Click += new System.EventHandler(this.buttonChooseFile_Click);
//
// MainForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(128)), ((System.Byte)(255)));
this.ClientSize = new System.Drawing.Size(462, 533);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.groupBox);
this.MaximumSize = new System.Drawing.Size(470, 560);
this.MinimumSize = new System.Drawing.Size(470, 560);
this.Name = "MainForm";
this.Text = "MainForm";
((System.ComponentModel.ISupportInitialize)(this.axWebBrowser)).EndInit();
this.groupBox.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.groupBox4.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// Point d'entr�e principal de l'application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new MainForm());
}
private void replaceTag(BMail pBMail) {
string vMethod= this.comboBoxHTMLTagReplacement.SelectedItem.ToString().Substring(0,1);
if (vMethod=="1") {
pBMail.replaceFrom("name", "John");
pBMail.replaceFrom("number", "1234");
pBMail.replaceFrom("year", DateTime.Now.Year.ToString());
} else
if (vMethod=="2") {
pBMail.replaceFromBMailId(BMailId.newFrom("name", "John"));
pBMail.replaceFromBMailId(BMailId.newFrom("number", "1234"));
pBMail.replaceFromBMailId(BMailId.newFrom("year", DateTime.Now.Year.ToString()));
} else {
BMailIdList vList= new BMailIdList();
vList.addFrom("name", "John");
vList.addFrom("number", "1234");
vList.addFrom("year", DateTime.Now.Year.ToString());
pBMail.replaceFromBMailIdList(vList);
}
}
private BMail getMail() {
// Create EMail and set Header
BMail vBMail= new BMail();
vBMail.From= this.textBoxFrom.Text;
vBMail.To= this.textBoxTo.Text;
if (this.textBoxCc.Text!="")
vBMail.Cc= this.textBoxCc.Text;
if (this.textBoxBcc.Text!="")
vBMail.Bcc= this.textBoxBcc.Text;
vBMail.Subject= this.textBoxSubject.Text;
if (this.checkBoxNotify.Checked)
vBMail.NotifyTo= this.textBoxFrom.Text;
// Set the body
vBMail.setBodyFromFile(this.textBoxHTMLFileName.Text, true);
this.replaceTag(vBMail);
// Add attachment if necessary
if (this.textBoxAttachement.Text!="")
vBMail.Attach= this.textBoxAttachement.Text;
// Set the server info
if (this.checkBoxUseSMTPServer.Checked) {
vBMail.SMTPAutenticate= BMail.SMTP_AUTH_BASIC;
vBMail.SMTPServer= this.textBoxSMTPServer.Text;
vBMail.SMTPUserName= this.textBoxSMTPLogin.Text;
vBMail.SMTPPassword= this.textBoxSMTPPassword.Text;
}
return vBMail;
}
private void buttonSend_Click(object sender, System.EventArgs e) {
// Get the BMail and send it
BMail vBMail= this.getMail();
bool vResult= vBMail.send();
if (vResult)
MessageBox.Show("EMail has been sent.", "BMail", MessageBoxButtons.OK, MessageBoxIcon.Information);
else
MessageBox.Show("Problem during EMail delivery.", "BMail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
private void buttonPreview_Click(object sender, System.EventArgs e) {
// 1) Get the BMail
BMail vBMail= this.getMail();
// 2) Create the file in the application current directory
string vEMailFile= "EMail.html";
string vCurrentDir= Directory.GetCurrentDirectory();
string vFileName= Path.Combine(vCurrentDir, vEMailFile);
FileStream fs = new FileStream(vFileName, FileMode.Create, FileAccess.Write);
StreamWriter m_streamWriter = new StreamWriter(fs);
m_streamWriter.WriteLine(vBMail.Body);
m_streamWriter.Close();
fs.Close();
// 3) Generate Preview
object o= null;
this.axWebBrowser.Navigate(vFileName,ref o,ref o,ref o,ref o);
/// If you need to work with the HTML document :
/// See: http://www.codeproject.com/csharp/webbrowser.asp
/// See: http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/mshtml/reference/ifaces/document2/document2.asp
/// ...
/// using MSHTML;
/// IHTMLDocument2 doc= (IHTMLDocument2)(axWebBrowser.Document);
}
/// <summary>
/// Manage utilization of an SMTP Server
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void checkBoxUseSMTPServer_CheckedChanged(object sender, System.EventArgs e) {
bool vChecked= this.checkBoxUseSMTPServer.Checked;
this.textBoxSMTPServer.Enabled= vChecked;
this.textBoxSMTPLogin.Enabled= vChecked;
this.textBoxSMTPPassword.Enabled= vChecked;
}
/// <summary>
/// Manage Attachment
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonChooseFile_Click(object sender, System.EventArgs e) {
openFileDialog.InitialDirectory = @"d:\temp";
openFileDialog.Filter = "Tous fichiers (*.*)|*.*" ;
openFileDialog.FilterIndex = 1 ;
openFileDialog.RestoreDirectory = true ;
if (openFileDialog.ShowDialog() == DialogResult.OK)
this.textBoxAttachement.Text= openFileDialog.FileName;
else
this.textBoxAttachement.Text= "";
}
}
}