Can i put semicomma seperated emailid in To using System.Net.Mail namespace
-
Hi all, I make one application in which i have one requirement that, i have to put multiple emailids with semicomma seperated like - "abc1@abc.com; abc2@abc.com; abc3@abc.com; ..." but its give me an error when i assign it in "To"!!!! When i put single emailid then it don't gives any error... Need some suggesion to solve this issue...
Krishnraj
-
Hi all, I make one application in which i have one requirement that, i have to put multiple emailids with semicomma seperated like - "abc1@abc.com; abc2@abc.com; abc3@abc.com; ..." but its give me an error when i assign it in "To"!!!! When i put single emailid then it don't gives any error... Need some suggesion to solve this issue...
Krishnraj
You need to write some code. Sorry about that. You need to turn your list of emails into a collection of addresses which get applied to the to and the bcc, I guess.
Christian Graus Driven to the arms of OSX by Vista.
-
You need to write some code. Sorry about that. You need to turn your list of emails into a collection of addresses which get applied to the to and the bcc, I guess.
Christian Graus Driven to the arms of OSX by Vista.
Hi Christian, First-of-all thanks for replying... there is no issue to put the code and here is my code...
Dim Strsmtp As New System.Net.Mail.MailMessage
' MailFrom and MailTo come from the database
Dim from As New System.Net.Mail.MailAddress(objReader("MailFrom").ToString())' Here i Put hard code emailids
Dim toList As New System.Net.Mail.MailAddress("abc1@abc.com;abc2@abc.com")
Strsmtp.From = from
Strsmtp.To.Add(toList)Strsmtp.Subject = "Hi"
Strsmtp.IsBodyHtml = True
Strsmtp.Headers.Add("Content-Type", objReader("MailContentType"))
Strsmtp.Headers.Add("Reply-To", objReader("MailReplyTo"))
Strsmtp.Body = "Test"
Dim sp As New System.Net.Mail.SmtpClient()
sp.Send(Strsmtp)and when i put the single emailid, then it gives different error that - Host Name is not specified. But i already specified host name in my web.config file. Here is the code..
<system.net>
<mailSettings>
<smtp>
<network host="localhost" />
</smtp>
</mailSettings>
</system.net>as i work in my local pc, so i write "localhost"... Now i don't understand what i have to do???:confused:
Krishnraj
-
Hi Christian, First-of-all thanks for replying... there is no issue to put the code and here is my code...
Dim Strsmtp As New System.Net.Mail.MailMessage
' MailFrom and MailTo come from the database
Dim from As New System.Net.Mail.MailAddress(objReader("MailFrom").ToString())' Here i Put hard code emailids
Dim toList As New System.Net.Mail.MailAddress("abc1@abc.com;abc2@abc.com")
Strsmtp.From = from
Strsmtp.To.Add(toList)Strsmtp.Subject = "Hi"
Strsmtp.IsBodyHtml = True
Strsmtp.Headers.Add("Content-Type", objReader("MailContentType"))
Strsmtp.Headers.Add("Reply-To", objReader("MailReplyTo"))
Strsmtp.Body = "Test"
Dim sp As New System.Net.Mail.SmtpClient()
sp.Send(Strsmtp)and when i put the single emailid, then it gives different error that - Host Name is not specified. But i already specified host name in my web.config file. Here is the code..
<system.net>
<mailSettings>
<smtp>
<network host="localhost" />
</smtp>
</mailSettings>
</system.net>as i work in my local pc, so i write "localhost"... Now i don't understand what i have to do???:confused:
Krishnraj
The issue is that the object you call
toList
is not a list but a single object. You must add a separate MailAddress object for each address in your string.*Developer Day Scotland - Free community conference Delegate Registration Open