C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » .NET »

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


Posted Date: 04 Jul 2008      Posted By: chiya      Member Level: Silver     Points: 1   Responses: 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: 4 out of 54 out of 54 out of 54 out of 5     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

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : multi system support for VB.NET application
Previous : send mail
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use