string DocName = ((Label)Repeater2.Items[i].FindControl("DocName")).Text; string emailId = ((Label)Repeater2.Items[i].FindControl("YourEamil")).Text; DropDownList dropdownvalue = ((DropDownList)Repeater2.Items[i].FindControl("DropDownList4")); string docname = String.Empty; string emailID = String.Empty; string dropdownvalues = String.Empty; // Next, we need to pass all three parameters to the email routine if (DocName.ToString() != "") { docname = DocName.ToString(); } else { docname = "Unavailable"; } if (emailId.ToString() != "") { emailID = emailId.ToString(); } else { emailID = "Unavailable"; } if (dropdownvalue.SelectedItem.ToString() != "") { dropdownvalues = dropdownvalue.SelectedItem.ToString(); } else { dropdownvalues = "Unavailable"; } //SendEmailUsingGmail(docname.ToString(), dropdownvalue.ToString(), emailId.ToString()); SendEmailUsingGmail(DocName.ToString(), emailId.ToString(), dropdownvalue.ToString()); cmd.ExecuteNonQuery(); //try //{ // cmd.ExecuteNonQuery(); // string emailId = ((Label)Repeater2.Items[i].FindControl("Label2")).Text; // SendEmailUsingGmail(string emailId); //} //catch (Exception ex) //{ // Supvisor.Text=(ex.Message); //} //try //{ // if (DropDownListcontrol != null) // { // if (DropDownListcontrol.SelectedValue == "1") // { // //get Current EMAIL_ID from the DataKey // string emailId = ((Label)Repeater2.Items[i].FindControl("Label2")).Text; // //write code to send mail // SendEmailUsingGmail(emailId); // dt.Clear(); // dt.Dispose(); // } // else if (DropDownListcontrol.SelectedValue == "3") // { // } // } //} //catch (Exception ex) //{ // Supvisor.Text = "Failed"; //} //finally //{ // empId = string.Empty; //} //UPDATE APPPROVEID IN DOCUMENTINFO TABLE //DMSLIB.Doc myDoc = new DMSLIB.Doc(); //myDoc.MarkDocAs(Convert.ToInt16(DocId.Text), Convert.ToInt32(DropDownListcontrol.SelectedValue)); } } else { Supvisor.Text = "Error"; } if (mySQLconnection.State == ConnectionState.Open) { mySQLconnection.Close(); } } private void SendEmailUsingGmail(string DocName, string emailId, string dropdownvalue) { try { SmtpClient smtp = new SmtpClient(); smtp.Credentials = new NetworkCredential("dfsdf4@gmail.com", "dsfsdf"); smtp.Port = 587; smtp.Host = "smtp.gmail.com"; smtp.EnableSsl = true; MailMessage message = new MailMessage(); message.From = new MailAddress("dfsdf4@gmail.com"); message.To.Add(emailId); //message.To.Add(New MailAddress(toEmailAddress)); message.Subject = "DropDownList4" + dropdownvalue; message.Body = "DocName=" + DocName + " DropDownList4=" + dropdownvalue; //message.Subject = "Write your email subject here"; //message.Body = "write the content of the email here"; smtp.Send(message); } catch (Exception ex) { Response.Write("Error occured: " + ex.Message.ToString()); } }
if (dropdownvalue.SelectedItem.ToString() != "") { dropdownvalues = dropdownvalue.SelectedValue.ToString(); }
if (dropdownvalue.SelectedItem.ToString() != "") { dropdownvalues = dropdownvalue.SelectedItem.ToString(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)