rachayita jaiswal

rachayita jaiswal

  • NA
  • 217
  • 103.9k

Send button id from one form to another in windows app

Aug 13 2013 12:44 AM
Hi,

I have created one application where i am using two form - 1) planform and 2) statusform
 and 3rd form i have created to send mail, I have done coding - 

public void sendmailbtn_Click(object sender, EventArgs e)
        {
            planform obj = new planform();
            statusform obj1 = new statusform(); 

            MailMessage mail = new MailMessage();
           
            mail.To.Add(tobox.Text);
            mail.From = new MailAddress(frombox.Text);
    mail.Subject = DateTime.Now.ToShortDateString() + "-Planned Task Register (PTR)"; // subject
            mail.Body = bodyboxarea.Text;
            mail.CC.Add(new MailAddress(ccbox.Text));
            mail.IsBodyHtml = true;           

            System.Net.Mail.Attachment attachment;
            attachment = new System.Net.Mail.Attachment(filebox.Text);
            mail.Attachments.Add(attachment);
            
            SmtpClient smtp = new SmtpClient();
            smtp.Host = "smtp.gmail.com";
            smtp.Credentials = new System.Net.NetworkCredential("gmailid", "password");
            smtp.EnableSsl = true;
            smtp.Send(mail);

            this.Hide();           
            MessageBox.Show("Mail sent");
        }

it is working fine, currently "subject" will be same for both plan and status but i want subject line should change when i ll click on status form
it should be like -

    mail.Subject = DateTime.Now.ToShortDateString() + "-StatusTask Register (PTR)"; // subject
   
            for this i have created global variable but still i did'nt get...
    how i ll do that??

Answers (3)