ASkEPA
asked on
How to send one mail to many recipients asp.net ?
Hello Experts.
How to send one mail to many recipients from my vb.net code ?
Included function works only for one recipient.
How to send one mail to many recipients from my vb.net code ?
Included function works only for one recipient.
Function WyslijEmail_html_LISTA_OSOB(ByVal _pobierzdo As String, ByVal _temat As String, ByVal _tresc As String) As String
Dim email_od As New MailAddress("obieg@epa", "Obieg Dokumentów")
Dim email_do As New MailAddress(_pobierzdo, _pobierzdo)
Dim msg As New MailMessage(email_od, email_do)
msg.Body = _tresc
msg.Subject = _temat
msg.IsBodyHtml = True
Dim mailSender As New System.Net.Mail.SmtpClient()
mailSender.Host = "192.168.2.10"
Try
mailSender.Send(msg)
Catch ex As Exception
WyslijEmail_html_LISTA_OSOB = ex.ToString
End Try
Return WyslijEmail_html_LISTA_OSOB
End Function
ASKER
i got errors :
property to is read only in line : mail.To = "me@mycompany.com;him@hisc ompany.com ;her@herco mpany.com"
and value of type string cannot be converted to system.net.mail.mailaddres in line : mail.From = "you@yourcompany.com"
and : SmtpMail is not declarated in lines :
SmtpMail.SmtpServer = "localhost" 'your real server goes here
SmtpMail.Send(mail)
property to is read only in line : mail.To = "me@mycompany.com;him@hisc
and value of type string cannot be converted to system.net.mail.mailaddres
and : SmtpMail is not declarated in lines :
SmtpMail.SmtpServer = "localhost" 'your real server goes here
SmtpMail.Send(mail)
You can also add them separatly ...
Function WyslijEmail_html_LISTA_OSO B(ByVal _pobierzdo As String, ByVal _temat As String, ByVal _tresc As String) As String
Dim email_od As New MailAddress("obieg@epa", "Obieg Dokumentów")
Dim email_do As New MailAddress(_pobierzdo, _pobierzdo)
Dim msg As New MailMessage(email_od, email_do)
msg.Add("test@test.com")
msg.Add("test2@test.Com")
...
Function WyslijEmail_html_LISTA_OSO
Dim email_od As New MailAddress("obieg@epa", "Obieg Dokumentów")
Dim email_do As New MailAddress(_pobierzdo, _pobierzdo)
Dim msg As New MailMessage(email_od, email_do)
msg.Add("test@test.com")
msg.Add("test2@test.Com")
...
ASKER
Can't do this because msg dosn't have add method.
What version of framework are you using ? I have just tested it here on my machine !
Sending Email from an ASP.NET 1.x Web Page
http://www.4guysfromrolla.com/webtech/080801-1.shtml
Sending Email in ASP.NET 2.0
http://aspnet.4guysfromrolla.com/articles/072606-1.aspx
Sending Email from an ASP.NET 1.x Web Page
http://www.4guysfromrolla.com/webtech/080801-1.shtml
Sending Email in ASP.NET 2.0
http://aspnet.4guysfromrolla.com/articles/072606-1.aspx
.NET 2.0
Dim mail As New System.Net.Mail.MailMessag e
mail.To.Add("test@test.com ")
mail.To.Add("test2@test.co m")
.NET 1.1
Dim mail2 As New System.Web.Mail.MailMessag e
mail2.To = "test@test.com; test2@test.com"
Dim mail As New System.Net.Mail.MailMessag
mail.To.Add("test@test.com
mail.To.Add("test2@test.co
.NET 1.1
Dim mail2 As New System.Web.Mail.MailMessag
mail2.To = "test@test.com; test2@test.com"
ASKER
I use .NET 2.0
Ok now this code works but i have to do this in one line "mail1@email.pl;mail2@emai l.pl" .... any idea how ?
Ok now this code works but i have to do this in one line "mail1@email.pl;mail2@emai
Dim ToAddress1 As String = "mail1@mail.pl"
Dim toaddress2 As String = "mail2@mail.pl"
Dim email_od As New MailAddress("obieg@epa", "Obieg Dokumentów")
Dim mm As New System.Net.Mail.MailMessage
mm.To.Add(ToAddress1)
mm.To.Add(toaddress2)
mm.From = email_od
mm.Subject = "temat"
mm.Body = "tre["
mm.IsBodyHtml = True
Dim mailSender As New System.Net.Mail.SmtpClient()
mailSender.Host = "192.168.2.10"
mailSender.Send(mm)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
mail.To = "me@mycompany.com;him@hisc
Source: http://www.systemwebmail.com/faq/2.6.aspx
Open in new window