• Web sitemizin içeriğine ve tüm hizmetlerimize erişim sağlamak için Web sitemize kayıt olmalı ya da giriş yapmalısınız. Web sitemize üye olmak tamamen ücretsizdir.
  • Sohbetokey.com ile canlı okey oynamaya ne dersin? Hem sohbet et, hem mobil okey oyna!
  • Soru mu? Sorun mu? ''Bir Sorum Var?'' sistemimiz aktiftir. Paylaşın beraber çözüm üretelim.

C# ile Mail Gonderme Programı

Üyelik Tarihi
7 Ocak 2015
Konular
4,091
Mesajlar
4,274
MFC Puanı
40
Kod:
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Web.Mail;

namespace SendMail
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
public bool attach1 = false;
public bool attach2 = false;
public bool attach3 = false;

#region Windows Form Designer Generated Variables

private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button clearButton;
private System.Windows.Forms.TextBox message;
private System.Windows.Forms.TextBox subject;
private System.Windows.Forms.TextBox from;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button sendButton;
private System.Windows.Forms.TextBox to;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.TextBox attachment1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.TextBox attachment2;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.TextBox attachment3;
private System.Windows.Forms.StatusBar status;
private System.Windows.Forms.OpenFileDialog fileDlg;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.Button button6;
private System.Windows.Forms.TabPage tabPage3;
private System.Windows.Forms.GroupBox groupBox5;
private System.Windows.Forms.NumericUpDown bombAmount;
private TabPage tabPage4;
private GroupBox groupBox6;
private TextBox smtpBox;
private RadioButton radioButton2;
private RadioButton radioButton1;
private TabPage tabPage5;
private Label label7;
private Label label6;
private Label label5;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

#endregion

public Form1()
{
//
// 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 **** Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#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 **** InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typ eof(Form1));
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.clearButton = new System.Windows.Forms.Button();
this.message = new System.Windows.Forms.TextBox();
this.subject = new System.Windows.Forms.TextBox();
this.from = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.sendButton = new System.Windows.Forms.Button();
this.to = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.button6 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.attachment3 = new System.Windows.Forms.TextBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.button5 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.attachment2 = new System.Windows.Forms.TextBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.button4 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.attachment1 = new System.Windows.Forms.TextBox();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.bombAmount = new System.Windows.Forms.NumericUpDown();
this.status = new System.Windows.Forms.StatusBar();
this.fileDlg = new System.Windows.Forms.OpenFileDialog();
this.tabPage4 = new System.Windows.Forms.TabPage();
this.groupBox6 = new System.Windows.Forms.GroupBox();
this.smtpBox = new System.Windows.Forms.TextBox();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.tabPage5 = new System.Windows.Forms.TabPage();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.groupBox1.SuspendLayout();
this.tabPage2.SuspendLayout();
this.groupBox4.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox2.SuspendLayout();
this.tabPage3.SuspendLayout();
this.groupBox5.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.b ombAmount)).BeginInit();
this.tabPage4.SuspendLayout();
this.groupBox6.SuspendLayout();
this.tabPage5.SuspendLayout();
this.SuspendLayout();
//
// tabControl1
//
this.tabControl1.Appearance = System.Windows.Forms.TabAppearance.Buttons;
this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Controls.Add(this.tabPage3);
this.tabControl1.Controls.Add(this.tabPage4);
this.tabControl1.Controls.Add(this.tabPage5);
this.tabControl1.******** = new System.Drawing.Point(24, 31);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(361, 377);
this.tabControl1.TabIndex = 1;
//
// tabPage1
//
this.tabPage1.BackColor = System.Drawing.SystemColors.ControlLight;
this.tabPage1.Controls.Add(this.groupBox1);
this.tabPage1.******** = new System.Drawing.Point(4, 25);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Size = new System.Drawing.Size(353, 34;
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "Compose Mail";
this.tabPage1.UseVisualStyleBackColor = true;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.clearButton);
this.groupBox1.Controls.Add(this.message);
this.groupBox1.Controls.Add(this.subject);
this.groupBox1.Controls.Add(this.from);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.sendButton);
this.groupBox1.Controls.Add(this.to);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.******** = new System.Drawing.Point(16, ;
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(304, 344);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Compose Mail";
//
// clearButton
//
this.clearButton.******** = new System.Drawing.Point(128, 312);
this.clearButton.Name = "clearButton";
this.clearButton.Size = new System.Drawing.Size(80, 23);
this.clearButton.TabIndex = 9;
this.clearButton.Text = "Clear";
this.clearButton.Click += new System.EventHandler(this.clearButton_Click);
//
// message
//
this.message.******** = new System.Drawing.Point(72, 12;
this.message.Multiline = true;
this.message.Name = "message";
this.message.Size = new System.Drawing.Size(192, 144);
this.message.TabIndex = 8;
//
// subject
//
this.subject.******** = new System.Drawing.Point(72, 96);
this.subject.Name = "subject";
this.subject.Size = new System.Drawing.Size(192, 21);
this.subject.TabIndex = 7;
//
// from
//
this.from.******** = new System.Drawing.Point(72, 64);
this.from.Name = "from";
this.from.Size = new System.Drawing.Size(192, 21);
this.from.TabIndex = 6;
//
// label4
//
this.label4.******** = new System.Drawing.Point(8, 12;
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(56, 23);
this.label4.TabIndex = 5;
this.label4.Text = "Message :";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label3
//
this.label3.******** = new System.Drawing.Point(8, 96);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(56, 23);
this.label3.TabIndex = 4;
this.label3.Text = "Subject :";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label2
//
this.label2.******** = new System.Drawing.Point(16, 64);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(48, 23);
this.label2.TabIndex = 3;
this.label2.Text = "From :";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// sendButton
//
this.sendButton.******** = new System.Drawing.Point(72, 280);
this.sendButton.Name = "sendButton";
this.sendButton.Size = new System.Drawing.Size(192, 23);
this.sendButton.TabIndex = 2;
this.sendButton.Text = "Send";
this.sendButton.Click += new System.EventHandler(this.sendButton_Click);
//
// to
//
this.to.******** = new System.Drawing.Point(72, 32);
this.to.Name = "to";
this.to.Size = new System.Drawing.Size(192, 21);
this.to.TabIndex = 1;
//
// label1
//
this.label1.******** = new System.Drawing.Point(16, 32);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(48, 23);
this.label1.TabIndex = 0;
this.label1.Text = "To :";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// tabPage2
//
this.tabPage2.BackColor = System.Drawing.SystemColors.ControlLight;
this.tabPage2.Controls.Add(this.groupBox4);
this.tabPage2.Controls.Add(this.groupBox3);
this.tabPage2.Controls.Add(this.groupBox2);
this.tabPage2.******** = new System.Drawing.Point(4, 25);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Size = new System.Drawing.Size(336, 363);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "Attachments";
this.tabPage2.UseVisualStyleBackColor = true;
//
// groupBox4
//
this.groupBox4.Controls.Add(this.button6);
this.groupBox4.Controls.Add(this.button3);
this.groupBox4.Controls.Add(this.attachment3);
this.groupBox4.******** = new System.Drawing.Point(16, 232);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(304, 8;
this.groupBox4.TabIndex = 2;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "Attachment 3";
//
// button6
//
this.button6.******** = new System.Drawing.Point(144, 56);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(75, 23);
this.button6.TabIndex = 2;
this.button6.Text = "Delete";
this.button6.Click += new System.EventHandler(this.button6_Click);
//
// button3
//
this.button3.******** = new System.Drawing.Point(64, 56);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 23);
this.button3.TabIndex = 1;
this.button3.Text = "Browse";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// attachment3
//
this.attachment3.******** = new System.Drawing.Point(8, 24);
this.attachment3.Name = "attachment3";
this.attachment3.ReadOnly = true;
this.attachment3.Size = new System.Drawing.Size(280, 21);
this.attachment3.TabIndex = 0;
//
// groupBox3
//
this.groupBox3.Controls.Add(this.button5);
this.groupBox3.Controls.Add(this.button2);
this.groupBox3.Controls.Add(this.attachment2);
this.groupBox3.******** = new System.Drawing.Point(16, 12;
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(304, 8;
this.groupBox3.TabIndex = 1;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Attachment 2";
//
// button5
//
this.button5.******** = new System.Drawing.Point(144, 56);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(75, 23);
this.button5.TabIndex = 2;
this.button5.Text = "Delete";
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// button2
//
this.button2.******** = new System.Drawing.Point(64, 56);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 1;
this.button2.Text = "Browse";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// attachment2
//
this.attachment2.******** = new System.Drawing.Point(8, 24);
this.attachment2.Name = "attachment2";
this.attachment2.ReadOnly = true;
this.attachment2.Size = new System.Drawing.Size(280, 21);
this.attachment2.TabIndex = 0;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.button4);
this.groupBox2.Controls.Add(this.button1);
this.groupBox2.Controls.Add(this.attachment1);
this.groupBox2.******** = new System.Drawing.Point(16, 24);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(304, 8;
this.groupBox2.TabIndex = 0;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Attachment 1";
//
// button4
//
this.button4.******** = new System.Drawing.Point(144, 56);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(75, 23);
this.button4.TabIndex = 2;
this.button4.Text = "Delete";
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// button1
//
this.button1.******** = new System.Drawing.Point(64, 56);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "Browse";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// attachment1
//
this.attachment1.******** = new System.Drawing.Point(8, 24);
this.attachment1.Name = "attachment1";
this.attachment1.ReadOnly = true;
this.attachment1.Size = new System.Drawing.Size(280, 21);
this.attachment1.TabIndex = 0;
//
// tabPage3
//
this.tabPage3.BackColor = System.Drawing.SystemColors.ControlLight;
this.tabPage3.Controls.Add(this.groupBox5);
this.tabPage3.******** = new System.Drawing.Point(4, 25);
this.tabPage3.Name = "tabPage3";
this.tabPage3.Size = new System.Drawing.Size(336, 363);
this.tabPage3.TabIndex = 2;
this.tabPage3.Text = "Batch Mode";
this.tabPage3.UseVisualStyleBackColor = true;
//
// groupBox5
//
this.groupBox5.Controls.Add(this.bombAmount);
this.groupBox5.******** = new System.Drawing.Point(32, 112);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(272, 100);
this.groupBox5.TabIndex = 1;
this.groupBox5.TabStop = false;
this.groupBox5.Text = "How many times, the same mail you want to send";
//
// bombAmount
//
this.bombAmount.******** = new System.Drawing.Point(72, 40);
this.bombAmount.Maximum = new decimal(new int[] {
5000,
0,
0,
0});
this.bombAmount.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.bombAmount.Name = "bombAmount";
this.bombAmount.Size = new System.Drawing.Size(120, 21);
this.bombAmount.TabIndex = 1;
this.bombAmount.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// status
//
this.status.******** = new System.Drawing.Point(0, 433);
this.status.Name = "status";
this.status.Size = new System.Drawing.Size(449, 22);
this.status.TabIndex = 2;
this.status.Text = "Ready.";
//
// tabPage4
//
this.tabPage4.BackColor = System.Drawing.SystemColors.ControlLight;
this.tabPage4.Controls.Add(this.groupBox6);
this.tabPage4.******** = new System.Drawing.Point(4, 25);
this.tabPage4.Name = "tabPage4";
this.tabPage4.Size = new System.Drawing.Size(336, 363);
this.tabPage4.TabIndex = 3;
this.tabPage4.Text = "SMTP Server";
this.tabPage4.UseVisualStyleBackColor = true;
//
// groupBox6
//
this.groupBox6.Controls.Add(this.radioButton2);
this.groupBox6.Controls.Add(this.radioButton1);
this.groupBox6.Controls.Add(this.smtpBox);
this.groupBox6.******** = new System.Drawing.Point(44, 72);
this.groupBox6.Name = "groupBox6";
this.groupBox6.Size = new System.Drawing.Size(239, 165);
this.groupBox6.TabIndex = 0;
this.groupBox6.TabStop = false;
this.groupBox6.Text = "Choose the SMTP Server : ";
//
// smtpBox
//
this.smtpBox.Enabled = false;
this.smtpBox.******** = new System.Drawing.Point(17, 10;
this.smtpBox.Name = "smtpBox";
this.smtpBox.Size = new System.Drawing.Size(202, 21);
this.smtpBox.TabIndex = 2;
//
// radioButton1
//
this.radioButton1.AutoSize = true;
this.radioButton1.Checked = true;
this.radioButton1.******** = new System.Drawing.Point(17, 41);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(124, 17);
this.radioButton1.TabIndex = 3;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "Default SMTP Server";
this.radioButton1.UseVisualStyleBackColor = true;
//
// radioButton2
//
this.radioButton2.AutoSize = true;
this.radioButton2.******** = new System.Drawing.Point(17, 73);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(143, 17);
this.radioButton2.TabIndex = 4;
this.radioButton2.Text = "Specify the SMTP Server";
this.radioButton2.UseVisualStyleBackColor = true;
this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChang ed);
//
// tabPage5
//
this.tabPage5.BackColor = System.Drawing.SystemColors.ControlLight;
this.tabPage5.Controls.Add(this.label7);
this.tabPage5.Controls.Add(this.label6);
this.tabPage5.Controls.Add(this.label5);
this.tabPage5.******** = new System.Drawing.Point(4, 25);
this.tabPage5.Name = "tabPage5";
this.tabPage5.Size = new System.Drawing.Size(353, 34;
this.tabPage5.TabIndex = 4;
this.tabPage5.Text = "About";
//
// label5
//
this.label5.AutoSize = true;
this.label5.******** = new System.Drawing.Point(89, 104);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(158, 13);
this.label5.TabIndex = 0;
this.label5.Text = "Programmer : Selçuk ÖZDOĞAN";
//
// label6
//
this.label6.AutoSize = true;
this.label6.******** = new System.Drawing.Point(104, 137);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(133, 13);
this.label6.TabIndex = 1;
this.label6.Text = "ITU Computer Engineering";
//
// label7
//
this.label7.AutoSize = true;
this.label7.******** = new System.Drawing.Point(89, 176);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(165, 13);
this.label7.TabIndex = 2;
this.label7.Text = "Contact : selcuk198@yahoo.com";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
this.BackColor = System.Drawing.SystemColors.ControlLight;
this.ClientSize = new System.Drawing.Size(449, 455);
this.Controls.Add(this.status);
this.Controls.Add(this.tabControl1);
this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
this.ForeColor = System.Drawing.SystemColors.HotTrack;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this. Icon")));
this.MaximizeBox = false;
this.Name = "Form1";
this.Text = "Mail Sending Tool With Attachments - Melancholy ®2005";
this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_ Paint);
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.tabPage2.ResumeLayout(false);
this.groupBox4.ResumeLayout(false);
this.groupBox4.PerformLayout();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.tabPage3.ResumeLayout(false);
this.groupBox5.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.b ombAmount)).EndInit();
this.tabPage4.ResumeLayout(false);
this.groupBox6.ResumeLayout(false);
this.groupBox6.PerformLayout();
this.tabPage5.ResumeLayout(false);
this.tabPage5.PerformLayout();
this.ResumeLayout(false);
#endregion

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

private **** clearButton_Click(object sender, System.EventArgs e)
{
to.Text = "";
from.Text = "";
subject.Text = "";
message.Text = "";
}

private **** sendButton_Click(object sender, System.EventArgs e)
{
if( to.Text == "" )
{
MessageBox.Show( "Enter the mail address to send mail", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning );
to.Focus();
return;
}
else if( from.Text == "" )
{
MessageBox.Show( "Enter your mail address", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning );
from.Focus();
return;
}
else if( subject.Text == "" )
{
MessageBox.Show( "Enter a subject for your mail", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning );
subject.Focus();
return;
}
else if( message.Text == "" )
{
MessageBox.Show( "Enter a mesage for your mail", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning );
message.Focus();
return;
}
else
{
status.Text = "Please wait...";
//SmtpMail.Send( from.Text, to.Text, subject.Text, message.Text );
MailMessage mail = new MailMessage();
mail.To = to.Text;
mail.From = from.Text;
mail.Subject = subject.Text;
mail.Body = message.Text;

if( attach1 == true )
mail.Attachments.Add( new MailAttachment( attachment1.Text ) );
if( attach2 == true )
mail.Attachments.Add( new MailAttachment( attachment2.Text ) );
if( attach3 == true )
mail.Attachments.Add( new MailAttachment( attachment3.Text ) );

if (radioButton2.Checked)
SmtpMail.SmtpServer = smtpBox.Text;
else
SmtpMail.SmtpServer = "mail.gmx.net";


try
{
MessageBox.Show("You choose the smtp server : " + SmtpMail.SmtpServer);
for (int i = 1; i <= bombAmount.Value; i++)
{
SmtpMail.Send( mail );
status.Text = "Your mail has been sent [ " + i.ToString() + " ]";
}
}
catch(Exception ex)
{
MessageBox.Show("A problem has occurred, make sure you are connected to internet. \r\n" + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
status.Text = "Ready.";
return;
}
status.Text = "Sending mail has been successful.";
MessageBox.Show( "Your mail has been sent", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information );
}
}

private **** button1_Click(object sender, System.EventArgs e)
{
fileDlg.Filter = "All Files (*.*)|*.*|All Files (*.*)|*.*";
fileDlg.Title = "Choose the attachment file";

if( fileDlg.ShowDialog() == DialogResult.OK )
{
attachment1.Text = fileDlg.FileName;
attach1 = true;
}

}

private **** button4_Click(object sender, System.EventArgs e)
{
attachment1.Text = "";
attach1 = false;
}

private **** button2_Click(object sender, System.EventArgs e)
{
fileDlg.Filter = "All Files (*.*)|*.*|All Files (*.*)|*.*";
fileDlg.Title = "Choose the attachment file";

if( fileDlg.ShowDialog() == DialogResult.OK )
{
attachment2.Text = fileDlg.FileName;
attach2 = true;
}
}

private **** button5_Click(object sender, System.EventArgs e)
{
attachment2.Text = "";
attach2 = false;
}

private **** button3_Click(object sender, System.EventArgs e)
{
fileDlg.Filter = "All Files (*.*)|*.*|All Files (*.*)|*.*";
fileDlg.Title = "Choose the attachment file";

if( fileDlg.ShowDialog() == DialogResult.OK )
{
attachment3.Text = fileDlg.FileName;
attach3 = true;
}
}

private **** button6_Click(object sender, System.EventArgs e)
{
attachment3.Text = "";
attach3 = false;
}

private **** button7_Click(object sender, System.EventArgs e)
{
MessageBox.Show( bombAmount.Value.ToString() );
}

private **** Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs pe)
{
Graphics g = pe.Graphics ;
Rectangle rect = new Rectangle(0, 0, this.Size.Width, this.Size.Height);
LinearGradientBrush lBrush = new LinearGradientBrush(rect, Color.Brown, Color.White, LinearGradientMode.BackwardDiagonal);
g.FillRectangle(lBrush, rect);
}

private **** radioButton2_CheckedChanged(object sender, EventArgs e)
{
if (radioButton2.Checked)
smtpBox.Enabled = true;
else
smtpBox.Enabled = false;
}
 
Üst