Как использовать цикл на базе индекса
public void Mail(GridViewRow grid) { StringBuilder strEmail = new StringBuilder(); //GridViewRow grid = GVEcDecision.Rows[0]; GridView gvChild = (GridView)grid.FindControl("GVInspectorDetails"); string StrInspector = string.Empty; Label lblInspector = null; string StrMobile = string.Empty; Label Mobile = null; if (gvChild != null) { foreach (GridViewRow row in gvChild.Rows) { if (row.RowType == DataControlRowType.DataRow) { Label Lblcheck = (Label)row.FindControl("lblemail"); lblInspector = (Label)row.FindControl("LblName"); strEmail.Append("," + Lblcheck.Text); string Inspectorname = Lblcheck.Text.ToString(); Mobile = (Label)row.FindControl("Mobile"); if (lblInspector != null) { StrInspector = lblInspector.Text; } if (Mobile != null) { StrMobile = Mobile.Text; } Label lblcollegename = (Label)grid.FindControl("lblcollegename"); Label lblinsptype = (Label)grid.FindControl("lblinsptype"); Label lblcoursespec = (Label)grid.FindControl("lblcoursespec"); string CollegeName = grid.Cells[4].Text; string insptype = grid.Cells[5].Text; string coursespec = grid.Cells[6].Text; Label LblSubInspectionType = (Label)grid.FindControl("LblSubInspectionType"); Label lblfroseat = (Label)grid.FindControl("lblfroseat"); Label lblIncrSeat = (Label)grid.FindControl("lblIncrSeat"); string subinsptype = LblSubInspectionType.Text.ToString(); string FormSeat = lblfroseat.Text.ToString(); string toSeat = lblIncrSeat.Text.ToString(); TextBox txt1 = (TextBox)grid.FindControl("TxtEnddate"); string ToDate = txt1.Text.ToString(); TextBox txt2 = (TextBox)grid.FindControl("TxtStartdate"); string FormDate = txt2.Text.ToString(); Label lblstate = (Label)grid.FindControl("lblStatename"); string State = lblstate.Text.ToString(); Label lblcity = (Label)grid.FindControl("lblcity"); string city = lblcity.Text.ToString(); StringBuilder mailbody = new StringBuilder(); System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(); string email = strEmail.ToString().Substring(1, strEmail.ToString().Length - 1); string[] emailList = email.Split(','); for (int j = 0; j <; emailList.Length; j++) // foreach (string value in emailList) { message.To.Add(new System.Net.Mail.MailAddress(emailList[j])); message.Subject = "Appointment of Council's Inspectors"; message.Body = StrInspector + "," + city + "," + StrMobile + " <br> <br>This is Confirmation mail that You have been appointed for inspection as per Your " + "availity after Telephonic Discussion.<br><br>" + "Particulars for the inspection to be held as under:-<br>" + " Course:-" + insptype + "<br>" + " Purpose:-" + subinsptype + "<br>" + " Seats:-" + toSeat + "<br>" + " City:-" + city + "<br>" + " State:-" + State + "<br>" + " Date:-" + FormDate + "To" + ToDate + "<br> <br>" + "You will get a Formal Letter from DCI including all details about the College to be inspected<br>" + "before one day to inspection to be held through mail<br><br>" + " The Dental Council of India has engaged M/s Balmer Lawrie & Co.Ltd., a Govt.of <br>" + " India authorized travel partner to make bookings of air-tickets,hotel accommodation <br>" + " and taxi for all the inspectors/Visitors of the Council while going on DCI inspection. <br>" + " Therefore the said travel partner will contact you regarding your travel plan and will <br>" + " make travel arrangements accordingly.in case of any query and clarification you may <br>" + "contact the travel partner's representative Mr.Omprakash at 9899604205,011- <br>" + "42524112 or E-mail:prakash.o@balmerlawrie.com & ridhi.s@vacationsexotica.com<br><br>" + "<Now, you are requested to complete your preparation for the aforesaid inspection.in case<br>" + "<of any query you may contact us: Contact No.011-23236544 & 9818189120 and E-mail us<br>" + "<at:inspection@dciindia.org<br><br>" + "Please acknowledge the receiving immediately by E-mail<br>" + "reply on inspections@dciindia.org.<br><br><br>" + "Thanking You<br><br>" + "Secretary<br>" + "Dental Council of India<br>" + "New Delhi<br><br>" + "Copy to:<br>" + "Mr.Omprakash and Ms.Ridhi,M/s.Balmer Lawrie & Co.Ltd.for furtherance in the<br>" + "matter."; } message.IsBodyHtml = true; MailAddress fromAddress = new MailAddress("inspections@dciindia.org", "DCI"); message.From = fromAddress; //added New MailAddress copy = new MailAddress("inspections@dciindia.org"); message.CC.Add(copy); //MailAddress copy1 = new MailAddress("prakash.o@balmerlawrie.com"); //message.CC.Add(copy1); //MailAddress copy2 = new MailAddress("ridhi.s@vacationsexotica.com"); //message.CC.Add(copy2); //End SmtpClient smtp = new SmtpClient(); smtp.Host = "mail.dciindia.org"; //smtp.EnableSsl = true; NetworkCredential credential = new NetworkCredential("inspections@dciindia.org", "getin@inspdci!1015"); smtp.Credentials = credential; smtp.Port = 26; smtp.Send(message); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Mail has been Successfully send')", true); } } } }
Что я уже пробовал:
выше приведен мой код, и он работает нормально -
я хочу знать, что получаю два индекса [0], [1] в списке электронной почты, так что я получаю только значение индекса [1], поэтому, пожалуйста, помогите мне
[no name]
"я хочу знать, что я делаю, когда получаю два письма в списке рассылки, а затем отправляю код по почте", - вы узнаете, как задавать вопросы, которые имеют смысл. Ваше заявление не имеет никакого смысла.