Protected Sub SendMail_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles SendMail.Click Try Dim SmtpServer As New SmtpClient() Dim mail As New MailMessage() SmtpServer.Credentials = New _ Net.NetworkCredential("fiona@gmail.com", "donkeyboat") SmtpServer.Port = 587 SmtpServer.Host = "smtp.gmail.com" SmtpServer.EnableSsl = True mail = New MailMessage() mail.From = New MailAddress("fiona@gmail.com") mail.To.Add("fionatyl@hotmail.com") mail.Subject = "Test Mail" mail.IsBodyHtml = True mail.Body = "This is for testing SMTP mail from GMAIL" SmtpServer.Send(mail) MsgBox("Mail Send") Catch ex As Exception MsgBox(ex.ToString) End Try End Sub
MailMessage.To
MailMessageCollection
Add method
string of mail addresses separated by comma character
Add method of To property of MailMessage object with the Addresses in a string separated by ,
mail.To.Add("add1@hotmail.com,add2@hotmail.com,add3@hotmail.com")
string addresses = "abc@123.com;def@123.com;ghi@123.com"; foreach(string address in addresses.split(';')) mail.To.Add(address)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)