Click here to Skip to main content
11,707,470 members (74,946 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#2.0
i have 5 fields in the datagridview .
i have sendmail click button to send mail.

select  clietname  Assetstype      percetage  amount exceptedpercentage
[]       ABC      equityAssets        25        1000    35.5   
 
         ABC      LiquidAssets        25        2000    25.5     
 
         ABC      DebtAssets          25        3000    15.5    
 
         ABC      cashandcashAssets   25        4000    25.5   
 

[]       XYZ       equityAssets        25        1000    35.5   
 
         XYZ        LiquidAssets        25       7000    25.5     
 
         XYZ       DebtAssets          25        8000    15.5    
 
         XYZ       cashandcashAssets   25        4000    25.5     


i wrote code in the sendmail button but second persons value is not getting correct.
My Code is:

for (int i = 0; i < dgvPortfolioRebalancingReminder.Rows.Count - 1; i++)
          {
 
              DataGridViewRow row = dgvPortfolioRebalancingReminder.Rows[i];
 
              if (Convert.ToBoolean(dgvPortfolioRebalancingReminder.Rows[i].Cells[0].Value) == true)
              {
                  if (row.Cells[1].Value.ToString() != "")
                  {
                      strFirstName = row.Cells[1].Value.ToString();
                  }
                  else
                  {
                      strFirstName = "";
                  }
 
                  if (row.Cells[6].Value.ToString() != "")
                  {
                      email = row.Cells[6].Value.ToString();
                  }
                  else
                  {
                      email = "";
                  }
 
                  double[] myArray1 = new double[dgvPortfolioRebalancingReminder.Rows.Count];
                  double[] myArray2 = new double[dgvPortfolioRebalancingReminder.Rows.Count];
                  double[] myArray3 = new double[dgvPortfolioRebalancingReminder.Rows.Count];
 
                  List<datagridviewrow> myArrayList1 = new List<datagridviewrow>();
                  myArrayList1.Add(row);
 

 

 

 

                  for (int j = i, k = 0; j < 8; j++, i++, k++)
                  {
 
                      if (dgvPortfolioRebalancingReminder.Rows[i].Cells[3].Value.ToString() != "")
                      {
 
                          myArray1[k] = Convert.ToDouble(dgvPortfolioRebalancingReminder.Rows[i].Cells[3].Value.ToString());
                      }
                      if (dgvPortfolioRebalancingReminder.Rows[i].Cells[4].Value.ToString() != "")
                      {
                          myArray2[k] = Convert.ToDouble(dgvPortfolioRebalancingReminder.Rows[i].Cells[4].Value.ToString());
                      }
 
                      if (dgvPortfolioRebalancingReminder.Rows[i].Cells[5].Value.ToString() != "")
                      {
                          myArray3[k] = Convert.ToDouble(dgvPortfolioRebalancingReminder.Rows[i].Cells[5].Value.ToString());
                      }
 
                  }
 

 

                      if (strequityassetsAmount != null)
                      {
                          strequityassetsAmount = myArray1[0].ToString();
 
                      }
                      else
                          strequityassetsAmount = "";
 

                      if (strdebtassetsamount != null)
                      {
 
                          strdebtassetsamount = myArray1[1].ToString();
                      }
                      else
                          strdebtassetsamount = "";
 

 
                      if (strcommoditiesamount != null)
                      {
 
                          strcommoditiesamount = myArray1[2].ToString();
                      }
                      else
 
                          strcommoditiesamount = "";
 
                      if (strcashandcash != "")
                      {
 

                          strcashandcash = myArray1[3].ToString();
                      }
                      else
                          strcashandcash = "";
 

 

 

                  strpercentageE = myArray3[1].ToString();
                  strpercentageD = myArray3[2].ToString();
                  strpercentageCo = myArray3[3].ToString();
                  strpercentageC = myArray3[4].ToString();
 

                  strExistingpercentageE = myArray2[1].ToString();
 

 
                  strExistingpercentageD = myArray2[2].ToString();
                  strExistingpercentageCo = myArray2[3].ToString();
                  strExistingpercentageC = myArray2[4].ToString();
 

 

                  if (dtPlannerName.Rows[0].ItemArray[0].ToString() != "")
                  {
                      strplannername = dtPlannerName.Rows[0].ItemArray[0].ToString();
                  }
                  else
                  {
                      strplannername = "";
                  }
 

                  if (dtCompanyname.Rows[0].ItemArray[0].ToString() != "")
                  {
                      strcompanyname = dtCompanyname.Rows[0].ItemArray[0].ToString();
                  }
                  else
                  {
                      strcompanyname = "";
                  }
 

                  if (dtCompanyContact.Rows[0].ItemArray[0].ToString() != "")
                  {
                      strcompanycontact = dtCompanyContact.Rows[0].ItemArray[0].ToString();
                  }
                  else
                  {
                      strcompanycontact = "";
                  }
 

                  Email newemail = new Email();
                  newemail.To = email;
                  newemail.From = CompanyMailAddress;
                  newemail.Cc = String.Empty;
                  newemail.Subject = "Portfolio Rebalancing Reminder";
                  strpath = Application.StartupPath + "\\HTMLTemplate\\PortfolioRebalancing.html";
 
                  System.IO.StreamReader mail_format_reader = new System.IO.StreamReader(strpath);
                  body = mail_format_reader.ReadToEnd();
 
                  mail_format_reader.Close();
                  body = body.Replace("<%name%>", strFirstName);
                  body = body.Replace("<%Equityamount%>",strequityassetsAmount);
                  body = body.Replace("<%Debtamount%>", strdebtassetsamount);
                  body = body.Replace("<%Commoditiesamount%>",strcommoditiesamount);
                  body = body.Replace("<%Cashamount%>", strcashandcash);
 
                  body = body.Replace("<%percentageE%>", strpercentageE);
                  body = body.Replace("<%percentageD%>", strpercentageD);
                  body = body.Replace("<%percentageCo%>",strpercentageCo);
                  body = body.Replace("<%percentageC%>", strpercentageC);
 
                  body = body.Replace("<%ExisitngE%>", strExistingpercentageE);
                  body = body.Replace("<%ExisitngD%>", strExistingpercentageD);
                  body = body.Replace("<%ExisitngCo%>",strExistingpercentageCo);
                  body = body.Replace("<%ExisitngC%>", strExistingpercentageC);
 

 
                  body = body.Replace("<%plannername%>", strplannername);
                  body = body.Replace("<%companyname%>", strcompanyname);
                  body = body.Replace("<%companycontact%>", strcompanycontact);
                  newemail.Body = body;
                  newemail.IsHtmlBody = true;
                  newemail.SendMail();

but i dont know to bind dyanamic array for second client or other client.plz
tell me how to do??
Posted 18-Mar-13 4:11am
Edited 18-Mar-13 5:06am
(no name)19.7K
v2
Comments
ThePhantomUpvoter at 18-Mar-13 10:28am
   
Please format your code so that it is at least readable.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Mika Wendelius 220
1 Maciej Los 195
2 OriginalGriff 148
3 Sergey Alexandrovich Kryukov 145
4 chainerlt 110
0 OriginalGriff 9,198
1 Sergey Alexandrovich Kryukov 8,562
2 CPallini 5,189
3 Maciej Los 4,921
4 Mika Wendelius 3,856


Advertise | Privacy | Mobile
Web01 | 2.8.150819.1 | Last Updated 18 Mar 2013
Copyright © CodeProject, 1999-2015
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