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??