SendMail ASP.NET 2.0: Multiple To's

S

sck10

Hello,

I am trying to send email to 4 people (str01 =
"p1.mysite.com,p2.mysite.com,p3.mysite.com") using the following:

Dim addrFrom As New MailAddress(str00)
Dim addrTo As New MailAddress(str01)

My problem is that only the first person receives the email. When I check
the variable addrTo the value is "p1.mysite.com". Any help with this would
be appreciated.
 
K

Karl Seguin [MVP]

A mailAddress is used for a single person, the To property of the
MailMessage is actually a collection...

ur supposed to do:

myMessage.To.Add(new MailAddress("email1'))
myMessage.To.Add(new MailAddress("email2'))
myMessage.To.Add(new MailAddress("email3'))

Karl
 
J

Juan T. Llibre

Mail recipients can also be added using the cc and bcc attributes.

static void MultipleRecipients()
{
//create the mail message
MailMessage mail = new MailMessage();

//set the addresses
//to specify a friendly 'from' name, we use a different ctor
mail.From = new MailAddress("(e-mail address removed)", "Me");

//since the To,Cc, and Bcc accept addresses,
//we can use the same technique as the From address
//since the To, Cc, and Bcc properties are collections,
//to add multiple addreses, we simply call .Add(...) multple times

mail.To.Add("(e-mail address removed)");
mail.To.Add("(e-mail address removed)");
mail.CC.Add("(e-mail address removed)");
mail.CC.Add("(e-mail address removed)");
mail.Bcc.Add("(e-mail address removed)");
mail.Bcc.Add("(e-mail address removed)");

//set the content
mail.Subject = "This is an email";
mail.Body = "this is the body content of the email.";

//send the message
SmtpClient smtp = new SmtpClient("127.0.0.1");
smtp.Send(mail);
}
 
V

VickZaro

OT: Can you retrieve your email address from the smtp web.config?

Juan T. Llibre said:
Mail recipients can also be added using the cc and bcc attributes.

static void MultipleRecipients()
{
//create the mail message
MailMessage mail = new MailMessage();

//set the addresses
//to specify a friendly 'from' name, we use a different ctor
mail.From = new MailAddress("(e-mail address removed)", "Me");

//since the To,Cc, and Bcc accept addresses,
//we can use the same technique as the From address
//since the To, Cc, and Bcc properties are collections,
//to add multiple addreses, we simply call .Add(...) multple times

mail.To.Add("(e-mail address removed)");
mail.To.Add("(e-mail address removed)");
mail.CC.Add("(e-mail address removed)");
mail.CC.Add("(e-mail address removed)");
mail.Bcc.Add("(e-mail address removed)");
mail.Bcc.Add("(e-mail address removed)");

//set the content
mail.Subject = "This is an email";
mail.Body = "this is the body content of the email.";

//send the message
SmtpClient smtp = new SmtpClient("127.0.0.1");
smtp.Send(mail);
}





"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:[email protected]...
 
J

Juan T. Llibre

Hello, VickZaro.

The pattern to follow is this one :

<myGroup>
<nestedGroup>
<mySection>
<add key="key_one" value="1"/>
<add key="key_two" value="2"/>
</mySection>
</nestedGroup>
</myGroup>
</configuration>

You can read the value of the configuration section defined in the preceding example as follows:

Dim config As NameValueCollection=ConfigurationSettings.GetConfig("myGroup/nestedGroup/mySection")
Response.Write("The value of key_one is " & Server.HtmlEncode(config("key_one")) & "<br>")
Response.Write("The value of key_two is " & Server.HtmlEncode(config("key_two")) )
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,266
Messages
2,571,075
Members
48,772
Latest member
Backspace Studios

Latest Threads

Top