Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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 9:31am
Comments
Zaf Khan at 8-Dec-12 16:21pm
   
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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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  
v2
Comments
Surendra0x2 at 9-Dec-12 4:12am
   
You're Posting Your Question in Wrong section Always use Post a Question widget :)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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
0 DamithSL 300
1 Zoltán Zörgő 170
2 OriginalGriff 150
3 Sergey Alexandrovich Kryukov 120
4 Maciej Los 115
0 OriginalGriff 7,740
1 DamithSL 5,769
2 Sergey Alexandrovich Kryukov 5,424
3 Maciej Los 5,076
4 Kornfeld Eliyahu Peter 4,539


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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100