using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net.Mail;
using System.Net.Mime;
namespace Gmail
{
public partial class Form1 : Form
{
MailMessage mail = new MailMessage();
public Form1()
{
InitializeComponent();
}
private void Button1_Click(object sender, EventArgs e)
{
SmtpClient SmtpServer = new SmtpClient();
SmtpServer.Credentials = new System.Net.NetworkCredential("your e-mail id", "password");
SmtpServer.Port = 587;
SmtpServer.Host = "smtp.gmail.com";
SmtpServer.EnableSsl = true;
mail = new MailMessage();
String[] addr = TextBox1.Text.Split(',');
try
{
mail.From = new MailAddress("your email id", "Developers", System.Text.Encoding.UTF8);
Byte i;
for( i = 0;i< addr.Length; i++)
mail.To.Add(addr[i]);
mail.Subject = TextBox3.Text;
mail.Body = TextBox4.Text;
if(ListBox1.Items.Count != 0)
{
for(i = 0;i<listbox1.items.count;i++)>
mail.Attachments.Add(new Attachment(ListBox1.Items[i].ToString()));
}
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
mail.ReplyTo = new MailAddress(TextBox1.Text);
SmtpServer.Send(mail);
MessageBox.Show("Mail Send");
}
catch (Exception ex){
MessageBox.Show(ex.ToString());
}
}
}
}