I have created a form with a list box called lstCompany which displays search data, search textboxes are the "Name" and "PostCode" of company. I have a table called tblCompany which contains CompanyNo(primary key) with company details in the database including email. I would like to know how I can send email to the companies that I search on the list box. I have done the code which only sends email to one person who i put in code. Below is the code for send button
        var fromAddress = new MailAddress("myemail", "name");
        var toAddress = new MailAddress("other person's email", "name");
        const string fromPassword = "password";
        const string subject = "Testing";
        const string body = "Testing";
        var smtp = new SmtpClient
        {
            Host = "smtp.gmail.com",
            Port = 587,
            EnableSsl = true,
            DeliveryMethod = SmtpDeliveryMethod.Network,
            UseDefaultCredentials = false,
            Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
        };
        using (var message = new MailMessage(fromAddress, toAddress)
        {
            Subject = subject,
            Body = body
        })
        {
            smtp.Send(message);
            MessageBox.Show("Your email has been sent!");
        }
    }