Israel

Israel

  • 701
  • 1.3k
  • 217.3k

Sending multiple emails with combobox's content addresses

Mar 29 2017 6:53 AM
Hi!
 
With these codes I can send one email to someone without problem. But I need to learn how to send multiple emails with email's addresses itens into my combobox. Mean into my combobox I have three (3) emails address:
 
I would like to know how can I send one by one all these three emails once. Then to help user to be sure that its sending. I need a label showing the number and counting the number of emails that its inside of my combobox. Or just showing a barchart counting from 0% until 100% when finish.
 
Please let see my codes and its works perfectly but only sending one email from a textbox. Now I need your help how sending three item's emails addresses from my combobox oneby one once:
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net.Mail; 
 
SmtpClient client1 = new SmtpClient("smtp.live.com", 25); //smtp.gmail.com // For Gmail
//smtp.live.com // Windows live / Hotmail
//smtp.mail.yahoo.com // Yahoo
//smtp.aim.com // AIM
//my.inbox.com // Inbox


//Authentication.
//This is where the valid email account comes into play. You must have a valid email account(with password) to give our program a place to send the mail from.

NetworkCredential cred = new NetworkCredential("[email protected]", "12345");

//To send an email we must first create a new mailMessage(an email) to send.
MailMessage Msg = new MailMessage();

// Sender e-mail address.
Msg.From = new MailAddress(textBox2.Text);//Nothing But Above Credentials or your credentials (*******@gmail.com)

// Recipient e-mail address.
Msg.To.Add(textBox2.Text);

// Assign the subject of our message.
Msg.Subject = "Accounting Report";

// Create the content(body) of our message.
Msg.Body = txtEmailContent.Text;

/*System.Net.Mail.Attachment attachment;
attachment = new System.Net.Mail.Attachment("c:/Scaner1.jpg");
Msg.Attachments.Add(attachment);*/


// Send our account login details to the client.
client1.Credentials = cred;

//Enabling SSL(Secure Sockets Layer, encyription) is reqiured by most email providers to send mail
client1.EnableSsl = true;

//Confirmation After Click the Button
//label1.Text = "Mail Sended Succesfully";

// Send our email.
client1.Send(Msg);
//}
//catch
//{
// If Mail Doesnt Send Error Mesage Will Be Displayed
//label1.Text = "Error"; 

Answers (7)