Click here to Skip to main content
15,889,527 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Hello i have my code to send datagridview to email and it is running very well.
The problem is that it is just sending to my email, and not to other people email :o ,
my email is the Network Credential :o . How can i send it to other people?

C#
Pesquisar_Items pesquisar = new Pesquisar_Items();

               var client = new SmtpClient("smtp.gmail.com", 587);
               client.EnableSsl = true;
               client.Credentials = new NetworkCredential("jpbritopoker@gmail.com", "***");

               var mail = new MailMessage();
               mail.From = new MailAddress("nervir@epnervir.com");
               mail.To.Add(textBox1.Text);
               mail.IsBodyHtml = true;
               mail.Subject = textBox2.Text;

               string mailBody = "<table width='100%' style='border:Solid 1px Black;'>"; ;

               foreach (DataGridViewRow row in itemDataGridView.Rows)
               {
                   mailBody += "<tr>";
                   foreach (DataGridViewCell cell in row.Cells)
                   {
                       mailBody += "<td>" + cell.Value + "</td>";
                   }
                   mailBody += "</tr>";
               }
               mailBody += "</table>";

               //your rest of the original code
               mail.Body = mailBody;
               client.Send(mail);
               MessageBox.Show("O email foi enviado com sucesso");
               this.Close();
Posted
Updated 15-May-13 5:22am
v2

1 solution

You just need to add the email addresses to the To.Add() method delimited by commas.
mail.To.Add("email2," + textBox2.Text + ", email3,email4")
 
Share this answer
 
v5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900