Click here to Skip to main content
15,891,925 members
Please Sign up or sign in to vote.
1.00/5 (1 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
Comments
Zaf Khan 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.

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);
    }
}
 
Share this answer
 
v2
Comments
Surendra0x2 9-Dec-12 4:12am    
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.....

C#
int seatNumber = 1;  //move this to outside of event btnKatil_Click
 
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