New ASP.NET 2.0 Mail Question

D

David Hearn

I am converting one of my ASP.NET 1.1 apps over to 2.0 and I see that the
old way of sending mail will still work, but I want to make it clean and
convert over to the new way of doing things. You used to be able to specify
CC and BCC recipients and now I can't figure out how to specify these.

I am using the following when converting:

Dim MailObj as New System.Net.Mail.SmtpClient
MailObj.Host = "myhost"
MailObj.Send(From.Text, To.Text, Subj.Text, Msg.Text)

So how do I specify CC and BCC for this?

Thanks in advance!
 
D

David Hearn

Thanks Christopher!

Christopher Reed said:
You still need to use MailMessage if you want to add CC and BCC
recipients. The Send method also works with a MailMessage object.
 
C

Christopher Reed

You still need to use MailMessage if you want to add CC and BCC recipients.
The Send method also works with a MailMessage object.
 
J

Juan T. Llibre

G

Guest

Hi David,

you may try something like this -

MailMessage msg = new MailMessage();
SmtpClient server = new SmtpClient();
msg.From = new MailAddress("(e-mail address removed)", "DisplayName");
msg.To.Add("(e-mail address removed)");
msg.CC.Add("(e-mail address removed), (e-mail address removed)");
msg.Bcc.Add("(e-mail address removed), (e-mail address removed), (e-mail address removed)");
msg.Subject = "Subject";
msg.Body = "Message Body";
msg.IsBodyHtml = true;
server.Host = "mailserver";
server.UseDefaultCredentials = true;
server.Send(msg);

HTH.

Kaustav Neogy.
 
C

Chris Huddle

David Hearn said:
I am converting one of my ASP.NET 1.1 apps over to 2.0 and I see that the
old way of sending mail will still work, but I want to make it clean and
convert over to the new way of doing things. You used to be able to specify
CC and BCC recipients and now I can't figure out how to specify these.

I am using the following when converting:

Dim MailObj as New System.Net.Mail.SmtpClient
MailObj.Host = "myhost"
MailObj.Send(From.Text, To.Text, Subj.Text, Msg.Text)

So how do I specify CC and BCC for this?

Thanks in advance!
 

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,093
Messages
2,570,609
Members
47,229
Latest member
bennettnguyen

Latest Threads

Top