C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




How to send a mail to all emailIDs in user table except one


Posted Date: 04 Jul 2008      Total Responses: 1

Posted By: chiya       Member Level: Silver     Points: 1



I am developing a page which consists of sending mails to all the MailIDs in the User table.In the same page i sent a mail to particular EmailID say x, after that I want to send another mail to remaining mailIDs except x. The first mail sending to X is successfully done,but the second mail sending to all except x is showing error that "Atleast one from address is required",But i mentioned from also.this is the code.

string qq="select email from tablename where email not in ('"+x@y.com+"')";
cmd = new SqlCommand(qq,conn);
dr = cmd.ExecuteReader();
while (dr.Read())
{

h = dr["email"].ToString();

MailMessage mail = new MailMessage();
mail.To =h;
mail.From = "admin@funlawn.com";
//mail.Cc = "admin@funlawn.com";
mail.Subject = "Winner Declared !";
mail.BodyFormat = MailFormat.Html;

string ml = "hi"
mail.Body = ml;
SmtpMail.SmtpServer = "127.0.0.1";
SmtpMail.Send(mail); //error coming in this line

}

Help me in this regard.....................





Responses

Author: arun kumar    04 Jul 2008Member Level: SilverRating:     Points: 6

string qq="select email from tablename";
cmd = new SqlCommand(qq,conn);
dr = cmd.ExecuteReader();
while (dr.Read())
{

h = dr["email"].ToString();
if(h!="x@y.com")
{
MailMessage mail = new MailMessage();
mail.To =h;
mail.From = "admin@funlawn.com";
//mail.Cc = "admin@funlawn.com";
mail.Subject = "Winner Declared !";
mail.BodyFormat = MailFormat.Html;

string ml = "hi"
mail.Body = ml;
SmtpMail.SmtpServer = "127.0.0.1";
SmtpMail.Send(mail);
}



Post Reply
You must Sign In to post a response.
Next : multi system support for VB.NET application
Previous : send mail
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use