Click here to Skip to main content
15,923,087 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Please find my requirement below & help me out..

I have front end with some textfields like name, qualification, DOB, Address etc... with submit button.

& I have array which contains mailID's

Now my requirement is When the user clicks submit button the should be delievered to all mailID's which are in the above array..

How can i do this?
Posted
Updated 20-Mar-12 3:24am
v2
Comments
Golois 20-Mar-12 10:00am    
Do you want it in C# or VB?
What is a mailID? is it an email address?

1 solution

hi,
try the following code at your Submmit button..


protected void btnSendmail_Click(object sender, EventArgs e)
{
// System.Web.Mail.SmtpMail.SmtpServer is obsolete in 2.0
// System.Net.Mail.SmtpClient is the alternate class for this in 2.0
SmtpClient smtpClient = new SmtpClient();
System.Web.Mail.MailMessage message = new System.Web.Mail.MailMessage();

try
{

MailAddress fromAddress = new MailAddress("admin1@yoursite.com", "Hrushi");
// You can specify the host name or ipaddress of your server
// Default in IIS will be localhost
smtpClient.Host = "localhost";

//Default port will be 25
smtpClient.Port = 25;

//From address will be given as a MailAddress Object
message.From = fromAddress;

// To address collection of MailAddress

message.Subject = "Feedback";
// CC and BCC optional
// MailAddressCollection class is used to send the email to various users
// You can specify Address as new MailAddress("admin1@yoursite.com")
message.CC.Add("admin1@yoursite.com");

//Body can be Html or text format
//Specify true if it is html message
message.IsBodyHtml = false;
//Message Body
message.Body = "name=" + name.Text + ", qualification=" + qualification.Text + ", DOB=" + DOB.Text + ", Address=" + Address.Text + "";
foreach (var _ToAdd in _arrayObject)
{
message.To.Add(_ToAdd.ToString());

// Send SMTP mail
smtpClient.Send(message);
}
lblStatus.Text = "Email successfully sent.";
}
catch (Exception ex)
{
lblStatus.Text = "Send Email Failed." + ex.Message;
}
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900