www.pudn.com > Remote_Mail_client.zip > MailForm.cs
// Created by WiB June 2003
// shy_dream@yahoo.com
// You may include the source code, modified source code, assembly
// within your own projects for either personal or commercial use
// with the only one restriction:
// don't change the name of project, library, namespace, assembly.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.Threading;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels.Http;
using System.Runtime.Remoting.Channels;
using System.IO;
using System.Resources;
using System.Reflection;
using System.Text;
using TI_MAPI;
using TI_MailService;
namespace Mailer
{
public class MailForm : System.Windows.Forms.Form
{
#region Variables
private WiB.Pinkie.Controls.ButtonXP buttonXP4;
private WiB.Pinkie.Controls.ButtonXP buttonXP3;
private WiB.Pinkie.Controls.ButtonXP buttonXP2;
private WiB.Pinkie.Controls.ButtonXP buttonXP1;
private System.Windows.Forms.Label label1;
private WiB.Pinkie.Controls.ButtonXP buttonCc;
private WiB.Pinkie.Controls.ButtonXP buttonTo;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.RichTextBox richTextBox;
private System.Windows.Forms.TextBox textSubject;
public System.Windows.Forms.TextBox textTo;
public System.Windows.Forms.TextBox textCC;
private System.ComponentModel.Container components = null;
private RemoteSess sess = null;
private MSGDATA pMsgData = null;
static ResourceManager rm;
ProcessError processError = new ProcessError();
private System.Windows.Forms.Label label;
private string[] path = null;
#endregion
#region Constructor
public MailForm()
{
rm = new ResourceManager("Mailer.Images", Assembly.GetExecutingAssembly());
InitializeComponent();
this.buttonTo.Scheme = WiB.Pinkie.Controls.ButtonXP.Schemes.Silver;
this.buttonCc.Scheme = WiB.Pinkie.Controls.ButtonXP.Schemes.Silver;
this.buttonXP1.Scheme = WiB.Pinkie.Controls.ButtonXP.Schemes.Silver;
this.buttonXP2.Scheme = WiB.Pinkie.Controls.ButtonXP.Schemes.Silver;
this.buttonXP3.Scheme = WiB.Pinkie.Controls.ButtonXP.Schemes.Silver;
this.buttonXP4.Scheme = WiB.Pinkie.Controls.ButtonXP.Schemes.Silver;
this.Icon = GetIcon("AppIcon");
this.CenterToScreen();
}
public static Icon GetIcon(string bmName)
{
return (Icon)rm.GetObject(bmName);
}
public static Bitmap GetBitmap(string bmName)
{
return (Bitmap)rm.GetObject(bmName);
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#endregion
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MailForm));
this.buttonXP4 = new WiB.Pinkie.Controls.ButtonXP();
this.buttonXP3 = new WiB.Pinkie.Controls.ButtonXP();
this.buttonXP2 = new WiB.Pinkie.Controls.ButtonXP();
this.buttonXP1 = new WiB.Pinkie.Controls.ButtonXP();
this.label1 = new System.Windows.Forms.Label();
this.buttonCc = new WiB.Pinkie.Controls.ButtonXP();
this.buttonTo = new WiB.Pinkie.Controls.ButtonXP();
this.label2 = new System.Windows.Forms.Label();
this.label = new System.Windows.Forms.Label();
this.richTextBox = new System.Windows.Forms.RichTextBox();
this.textSubject = new System.Windows.Forms.TextBox();
this.textTo = new System.Windows.Forms.TextBox();
this.textCC = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// buttonXP4
//
this.buttonXP4._Image = null;
this.buttonXP4.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(212)), ((System.Byte)(208)), ((System.Byte)(200)));
this.buttonXP4.DefaultScheme = false;
this.buttonXP4.DialogResult = System.Windows.Forms.DialogResult.None;
this.buttonXP4.Image = ((System.Drawing.Bitmap)(resources.GetObject("buttonXP4.Image")));
this.buttonXP4.Location = new System.Drawing.Point(586, 168);
this.buttonXP4.Name = "buttonXP4";
this.buttonXP4.Scheme = WiB.Pinkie.Controls.ButtonXP.Schemes.Silver;
this.buttonXP4.Size = new System.Drawing.Size(74, 24);
this.buttonXP4.TabIndex = 39;
this.buttonXP4.Text = "F&ont";
this.buttonXP4.Click += new System.EventHandler(this.buttonXP4_Click);
//
// buttonXP3
//
this.buttonXP3._Image = null;
this.buttonXP3.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(212)), ((System.Byte)(208)), ((System.Byte)(200)));
this.buttonXP3.DefaultScheme = false;
this.buttonXP3.DialogResult = System.Windows.Forms.DialogResult.None;
this.buttonXP3.Image = ((System.Drawing.Bitmap)(resources.GetObject("buttonXP3.Image")));
this.buttonXP3.Location = new System.Drawing.Point(586, 232);
this.buttonXP3.Name = "buttonXP3";
this.buttonXP3.Scheme = WiB.Pinkie.Controls.ButtonXP.Schemes.Silver;
this.buttonXP3.Size = new System.Drawing.Size(74, 24);
this.buttonXP3.TabIndex = 38;
this.buttonXP3.Text = "Print";
//
// buttonXP2
//
this.buttonXP2._Image = null;
this.buttonXP2.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(212)), ((System.Byte)(208)), ((System.Byte)(200)));
this.buttonXP2.DefaultScheme = false;
this.buttonXP2.DialogResult = System.Windows.Forms.DialogResult.None;
this.buttonXP2.Image = ((System.Drawing.Bitmap)(resources.GetObject("buttonXP2.Image")));
this.buttonXP2.Location = new System.Drawing.Point(586, 200);
this.buttonXP2.Name = "buttonXP2";
this.buttonXP2.Scheme = WiB.Pinkie.Controls.ButtonXP.Schemes.Silver;
this.buttonXP2.Size = new System.Drawing.Size(74, 24);
this.buttonXP2.TabIndex = 37;
this.buttonXP2.Text = "Save";
//
// buttonXP1
//
this.buttonXP1._Image = null;
this.buttonXP1.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(212)), ((System.Byte)(208)), ((System.Byte)(200)));
this.buttonXP1.DefaultScheme = false;
this.buttonXP1.DialogResult = System.Windows.Forms.DialogResult.None;
this.buttonXP1.Image = ((System.Drawing.Bitmap)(resources.GetObject("buttonXP1.Image")));
this.buttonXP1.Location = new System.Drawing.Point(586, 128);
this.buttonXP1.Name = "buttonXP1";
this.buttonXP1.Scheme = WiB.Pinkie.Controls.ButtonXP.Schemes.Silver;
this.buttonXP1.Size = new System.Drawing.Size(74, 24);
this.buttonXP1.TabIndex = 36;
this.buttonXP1.Text = "&Send";
this.buttonXP1.Click += new System.EventHandler(this.buttonXP1_Click);
//
// label1
//
this.label1.BackColor = System.Drawing.Color.Transparent;
this.label1.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.label1.Location = new System.Drawing.Point(16, 64);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 20);
this.label1.TabIndex = 35;
this.label1.Text = "Sub&ject:";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// buttonCc
//
this.buttonCc._Image = null;
this.buttonCc.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(212)), ((System.Byte)(208)), ((System.Byte)(200)));
this.buttonCc.DefaultScheme = false;
this.buttonCc.DialogResult = System.Windows.Forms.DialogResult.None;
this.buttonCc.Image = null;
this.buttonCc.Location = new System.Drawing.Point(8, 40);
this.buttonCc.Name = "buttonCc";
this.buttonCc.Scheme = WiB.Pinkie.Controls.ButtonXP.Schemes.Silver;
this.buttonCc.Size = new System.Drawing.Size(74, 20);
this.buttonCc.TabIndex = 33;
this.buttonCc.Text = "Cc...";
this.buttonCc.Click += new System.EventHandler(this.buttonCc_Click);
//
// buttonTo
//
this.buttonTo._Image = null;
this.buttonTo.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(212)), ((System.Byte)(208)), ((System.Byte)(200)));
this.buttonTo.DefaultScheme = false;
this.buttonTo.DialogResult = System.Windows.Forms.DialogResult.None;
this.buttonTo.Image = null;
this.buttonTo.Location = new System.Drawing.Point(8, 16);
this.buttonTo.Name = "buttonTo";
this.buttonTo.Scheme = WiB.Pinkie.Controls.ButtonXP.Schemes.Silver;
this.buttonTo.Size = new System.Drawing.Size(74, 20);
this.buttonTo.TabIndex = 32;
this.buttonTo.Text = "To...";
this.buttonTo.Click += new System.EventHandler(this.buttonTo_Click);
//
// label2
//
this.label2.BackColor = System.Drawing.Color.Transparent;
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(24, 106);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(80, 16);
this.label2.TabIndex = 40;
this.label2.Text = "Attachments:";
//
// label
//
this.label.BackColor = System.Drawing.Color.Transparent;
this.label.Cursor = System.Windows.Forms.Cursors.Hand;
this.label.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.label.Location = new System.Drawing.Point(104, 106);
this.label.Name = "label";
this.label.Size = new System.Drawing.Size(570, 16);
this.label.TabIndex = 41;
this.label.Text = "[ Add Attachments ]";
this.label.Click += new System.EventHandler(this.label3_Click);
//
// richTextBox
//
this.richTextBox.AutoSize = true;
this.richTextBox.CausesValidation = false;
this.richTextBox.Location = new System.Drawing.Point(24, 128);
this.richTextBox.Name = "richTextBox";
this.richTextBox.Size = new System.Drawing.Size(552, 296);
this.richTextBox.TabIndex = 42;
this.richTextBox.Text = "";
//
// textSubject
//
this.textSubject.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.textSubject.Location = new System.Drawing.Point(88, 64);
this.textSubject.Name = "textSubject";
this.textSubject.Size = new System.Drawing.Size(582, 20);
this.textSubject.TabIndex = 45;
this.textSubject.Text = "";
//
// textTo
//
this.textTo.AllowDrop = true;
this.textTo.CausesValidation = false;
this.textTo.Location = new System.Drawing.Point(88, 16);
this.textTo.Name = "textTo";
this.textTo.Size = new System.Drawing.Size(582, 20);
this.textTo.TabIndex = 43;
this.textTo.Text = "Ala Valeria";
//
// textCC
//
this.textCC.Location = new System.Drawing.Point(88, 40);
this.textCC.Name = "textCC";
this.textCC.Size = new System.Drawing.Size(582, 20);
this.textCC.TabIndex = 44;
this.textCC.Text = "";
//
// MailForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(680, 451);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.buttonXP1,
this.textSubject,
this.textTo,
this.textCC,
this.richTextBox,
this.label,
this.label2,
this.buttonXP4,
this.buttonXP3,
this.buttonXP2,
this.label1,
this.buttonCc,
this.buttonTo});
this.Name = "MailForm";
this.Text = "Untitled - Message (Rich Text)";
this.Load += new System.EventHandler(this.MailForm_Load);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.MailForm_Paint);
this.ResumeLayout(false);
}
#endregion
#region Main
[STAThread]
static void Main()
{
Application.Run(new MailForm());
}
private void MailForm_Load(object sender, System.EventArgs e)
{
RemotingConfiguration.Configure("mailer.exe.config");
sess = new RemoteSess();
pMsgData = new MSGDATA();
}
#endregion
#region Paint
private void MailForm_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Pen pen = new Pen(Color.FromArgb(102, 102, 126), 2);
SolidBrush brush1 = new SolidBrush(Color.FromArgb(102, 102, 126));
LinearGradientBrush brush0 = new LinearGradientBrush(new Rectangle(10, 95, 660, 345), Color.FromArgb(242, 241, 243), Color.FromArgb(204, 206, 210), 90.0f);
float[] relativeIntensities = {0.0f, 0.3f, 1.0f};
float[] relativePositions = {0.0f, 0.7f, 1.0f};
Blend blend = new Blend();
blend.Factors = relativeIntensities;
blend.Positions = relativePositions;
brush0.Blend = blend;
PointF[] points = { new Point(10, 95),
new Point(670, 95),
new Point(670, 440),
new Point(10, 440),
new Point(10, 94)};
e.Graphics.FillRectangle(brush0, 10, 95, 660, 345);
e.Graphics.DrawLines(pen, points);
String text0 = @"Remote Mail";
Font font = new Font("Microsoft Sans Serif", 14, FontStyle.Bold, GraphicsUnit.Point);
StringFormat format = new StringFormat();
format.FormatFlags = StringFormatFlags.DirectionVertical;
e.Graphics.DrawString(text0, font, brush1, 640.0f, 305.0f, format);
pen.Dispose();
brush1.Dispose();
brush0.Dispose();
}
#endregion
#region AddressBook
private void buttonTo_Click(object sender, System.EventArgs e)
{
ShowAddressBook();
}
private void buttonCc_Click(object sender, System.EventArgs e)
{
ShowAddressBook();
}
private void ShowAddressBook()
{
try
{
AddressBook dlg = new AddressBook();
dlg.listBox.Items.Clear();
String[] pAddrList = sess.AddressList(1024);
for (int i=0; i<528; i++)
{
if (pAddrList[i] == null) break;
dlg.listBox.Items.Add(pAddrList[i]);
}
if (dlg.ShowDialog(this) == DialogResult.OK)
{
if (this.textTo.Text.Length != 0) this.textTo.Text += @"; ";
for (int k=0; k=0)
{
pMsgData.recipient_email[k] = name[k];
pMsgData.recipient_name[k] = null;
}
else
{
pMsgData.recipient_email[k] = null;
pMsgData.recipient_name[k] = name[k];
}
}
// carbon copy
string cc = this.textCC.Text;
string[] carbon_copy = new string[256];
carbon_copy = cc.Split(separator, 256);
pMsgData.carbon_copy = new string[carbon_copy.Length];
for (int k=0; k