Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > .NET Framework 2.0
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
.NET Framework 2.0 For discussion of the Microsoft .NET Framework 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 2.0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 24th, 2007, 11:07 AM
Authorized User
 
Join Date: Jan 2006
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default email- from web form

Hi
I am trying to add email functionality to my web form..first is SMTP a good option..what are the disadvantes,advantages.

Also I have the following piece of code that sends email to one person ,cc,bcc.
How can I modify it to send it to a distribution list.

try
  {
// Construct a new mail message and fill it with information from the form
   MailMessage aMessage = new MailMessage();
   aMessage.From = FromTextBox.Text;
   aMessage.To = ToTextBox.Text;
   aMessage.Cc = CCTextBox.Text;
   aMessage.Bcc = BCCTextBox.Text;
   aMessage.Subject = SubjectTextBox.Text;
   aMessage.Body = MessageTextBox.Text;
// if an attachment file is indicated, create it and add it to the message
   if (AttachmentTextBox.Text.Length > 0)
      aMessage.Attachments.Add(new MailAttachment(AttachmentTextBox.Text, MailEncoding.Base64));

// Now send the message
    SmtpMail.Send(aMessage);


}

catch(Exception ex)
 {

 }

}

Thanks.


Reply With Quote
  #2 (permalink)  
Old July 24th, 2007, 11:29 AM
Authorized User
 
Join Date: Sep 2004
Location: Edegem, Antwerpen, Belgium.
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

If you check the below link, you can see that the To, Cc and Bcc properties are from type MaillAddressCollection.

http://msdn2.microsoft.com/en-us/library/system.net.mail.mailmessage.to(vs.80).aspx

This means that you first need to create an instance of the MailAddressCollection, add the recipients to it and then assign it to the MailMessage.

Greetz,

Geert

http://geertverhoeven.blogspot.com
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Web Form Email Job Problem kwilliams ASP.NET 2.0 Professional 2 June 24th, 2008 02:27 PM
Web page email ashuphp Beginning PHP 1 April 19th, 2007 12:03 AM
set Focus to web control in Web form vivekshah C# 1 June 17th, 2006 03:25 AM



All times are GMT -4. The time now is 04:41 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.