Click here to Skip to main content
Sign Up to vote bad
good
Hi everyone,
I want to send numbers (for ex. 1 to 100) to users mail who visit the site and write his/her e-mail address to textbobox. i can send mail. But i have a problem during incresing number. When i run the program , it send number "1" again and again. i'm send mail to abc@... then i'm sending to abcd@... but program send number "1" at each turn, not number 2,3,4,5...
 
thanks in advance...
Posted 8 Dec '12 - 8:31

Comments
Zaf Khan - 8 Dec '12 - 16:21
You have to post your code so that someone can help you find the issue. Without it theresnt way of knowing where your going. Thanks.

2 solutions

When user open the main page, he write his name ,surname, mail address... then program will send numbers to users by mail.
 
    protected void btnKatil_Click(object sender, EventArgs e)
    {
        Label1.Text = TextBox1.Text;
        Label2.Text = TextBox2.Text;
        Label3.Text = TextBox3.Text;
 
        int seatNumber = 1;  //i want to increase this number each time and send mail
        
        MailMessage mail = new MailMessage();  
 
        mail.To.Add(TextBox3.Text);
        mail.From = new MailAddress("abcx@gmail.com");
        mail.Subject = "MailSubject" ;
        mail.Body = "Dear " + TextBox1.Text + " " + TextBox2.Text + " Seat Number : " + seatNumber.ToString();
        mail.IsBodyHtml = true;
        
        SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
        client.EnableSsl = true;
 
        NetworkCredential credentials = new NetworkCredential("abcx@gmail.com", "password");
        client.Credentials = credentials;
        try
        {
            client.Send(mail);
 
            seatNumber++;
 
        }
        
        catch (Exception hata)
        {
            Response.Write(hata);
        }
    }
 
  Permalink  
Comments
Surendra0x2 - 9 Dec '12 - 4:12
You're Posting Your Question in Wrong section Always use Post a Question widget :)
Declare this variable at the class /Page level or maintain it in the session. Because it is getting assigned the value '1' every time btnKatil_Click event is fired.....
 
  int seatNumber = 1;  //move this to outside of event btnKatil_Click
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 OriginalGriff 293
1 Sergey Alexandrovich Kryukov 143
2 Mohammed Hameed 123
3 Santhosh G_ 108
4 Lohith Korupolu 85
0 Sergey Alexandrovich Kryukov 8,266
1 OriginalGriff 6,306
2 CPallini 3,528
3 Rohan Leuva 2,703
4 Maciej Los 2,234


Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 9 Dec 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid