我会在每次比赛间隔后向我们的用户发送有关更新分数的电子邮件。为此,我正在发送具有相同主题相同消息正文的电子邮件,只是更新了间隔分数。因此,当我在移动浏览器中打开我的电子邮件时,它会创建一组电子邮件,并在我发送单个邮件时与我的邮件格式重叠,它将正确显示。但无法在分组中正确显示。我认为它对它进行了分组,因为与电子邮件 ID 相同。它在桌面浏览器上正确显示。所以我该如何解决它,请帮助我。
private static StringBuilder createstringformat_forsendingMail(DataTable dtTeamscoreDB, int Qtrno, string Quater)
{
StringBuilder strTable = new StringBuilder();
string strnotes = "",str;
int flag = 0;
bool OTAdded = false;
try
{
string strTeam1 = "", strTeam2 = "", strOTteam1score = "", strOTteam2score = "", strFinalScore1 = "", strFinalScore2="";
strTeam1 = dtTeamscoreDB.Rows[0]["team1name"].ToString();
strTeam2 = dtTeamscoreDB.Rows[0]["team2name"].ToString();
DataTable dtTeam = new DataTable();
dtTeam.Columns.Add("Qtr");
dtTeam.Columns.Add("Teamscore1");
dtTeam.Columns.Add("Teamscore2");
for (int i = 1; i <= Qtrno; i++)
{
DataRow dtrow = dtTeam.NewRow();
dtrow["Qtr"] = "Qtr" + i;
//dtTeam.Rows.Add[i]["Qtr"] = "Qtr" + i;
for (int dt = 0; dt < dtTeamscoreDB.Rows.Count; dt++)
{
if (Convert.ToInt32(dtTeamscoreDB.Rows[dt]["interval_id"].ToString()) == i)
{
dtrow["Teamscore1"] = dtTeamscoreDB.Rows[dt]["team1score"].ToString();
dtrow["Teamscore2"] = dtTeamscoreDB.Rows[dt]["team2score"].ToString();
}
if (dtTeamscoreDB.Rows[dt]["interval_name"].ToString() == "OT")
{
strOTteam1score = dtTeamscoreDB.Rows[dt]["team1score"].ToString();
strOTteam2score = dtTeamscoreDB.Rows[dt]["team2score"].ToString();
}
if (dtTeamscoreDB.Rows[dt]["interval_name"].ToString() == "F")
{
strFinalScore1 = dtTeamscoreDB.Rows[dt]["team1score"].ToString();
strFinalScore2 = dtTeamscoreDB.Rows[dt]["team2score"].ToString();
}
}
dtTeam.Rows.Add(dtrow);
dtTeam.AcceptChanges();
}
//if OT is not present then add blank
DataRow dtOTrow = dtTeam.NewRow();
dtOTrow["Qtr"] = "OT";
dtOTrow["Teamscore1"] = strOTteam1score;
dtOTrow["Teamscore2"] = strOTteam2score;
dtTeam.Rows.Add(dtOTrow);
if (Qtrno == 9)
{
DataRow dtOTrow1 = dtTeam.NewRow();
dtOTrow1["Qtr"] = "F";
dtOTrow1["Teamscore1"] = strFinalScore1;
dtOTrow1["Teamscore2"] = strFinalScore2;
dtTeam.Rows.Add(dtOTrow1);
}
dtTeam.AcceptChanges();
strTable.Append("<pre><table style='width:480px;border-Top: 1px solid #000000;' border='0' cellpadding='0' cellspacing='0' >");
strTable.Append("<tr><td style='border-left: 1px solid #000000;border-right: 1px solid #000000;border-bottom: 1px solid #000000;' align='center'> " + dtTeamscoreDB.Rows[0]["team1name"].ToString() + "</td>");
strTable.Append("<td style='border-right: 1px solid #000000;border-bottom: 1px solid #000000;' align='center'> " + dtTeamscoreDB.Rows[0]["team2name"].ToString() + "</td></tr>");
strTable.Append("<tr><td align='center' style='border-left: 1px solid #000000;border-right: 1px solid #000000;'>" + dtTeamscoreDB.Rows[dtTeamscoreDB.Rows.Count - 1]["team1score"].ToString() + "</td>");
strTable.Append("<td align='center' style='border-right: 1px solid #000000;'>" + dtTeamscoreDB.Rows[dtTeamscoreDB.Rows.Count - 1]["team2score"].ToString() + "</td></tr>");
strTable.Append("<tr><td colspan='2' style='border-top: 1px solid #000000;'> </td> </tr>");
strTable.Append("<tr><td colspan='2'>");
strTable.Append("<table cellpadding='0' border='0' cellspacing='0' style='width:480px;border: 1px solid #000000;'>");
strTable.Append("<tr><td style='border-right:1px solid #000000;border-bottom: 1px solid #000000;'><b> </b></td>");
//strTable.Append("<td style='border-right: 1px solid #000000;border-bottom: 1px solid #000000;'><b> " + strTeam1 + "</b></td>");
//strTable.Append("<td style='border-bottom: 1px solid #000000;'><b> " + strTeam2 + "</b></td></tr>");
for (int i = 1; i <= Qtrno; i++)
{
if (Qtrno == 9)
{
strTable.Append("<td style='border-right: 1px solid #000000;border-bottom: 1px solid #000000;'><b> " + i + "</b></td>");
//strTable.Append("<td style='border-right: 1px solid #000000;border-bottom: 1px solid #000000;'> " + dtTeam.Rows[i - 1]["Teamscore1"].ToString() + "</td>");
//strTable.Append("<td style='border-bottom: 1px solid #000000;'> " + dtTeam.Rows[i - 1]["Teamscore2"].ToString() + "</td></tr>");
}
else
{
if (Quater == "Q")
{
strTable.Append("<td style='border-right: 1px solid #000000;border-bottom: 1px solid #000000;'><b> " + i + "</b></td>");
//strTable.Append("<td style='border-right: 1px solid #000000;border-bottom: 1px solid #000000;'> " + dtTeam.Rows[i - 1]["Teamscore1"].ToString() + "</td>");
//strTable.Append("<td style='border-bottom: 1px solid #000000;'> " + dtTeam.Rows[i - 1]["Teamscore2"].ToString() + "</td></tr>");
}
else
{
strTable.Append("<td style='border-right: 1px solid #000000;border-bottom: 1px solid #000000;'><b> " + i + "</b></td>");
//strTable.Append("<td style='border-right: 1px solid #000000;border-bottom: 1px solid #000000;'> " + dtTeam.Rows[i - 1]["Teamscore1"].ToString() + "</td>");
//strTable.Append("<td style='border-bottom: 1px solid #000000;'> " + dtTeam.Rows[i - 1]["Teamscore2"].ToString() + "</td></tr>");
}
}
}
if (Qtrno == 9)
{
strTable.Append("<td style='border-bottom: 1px solid #000000;border-Right: 1px solid #000000;'><b> Extra</b></td>");
strTable.Append("<td style='border-bottom: 1px solid #000000;'><b> F</b></td></tr>");
}
else
{
strTable.Append("<td style='border-bottom: 1px solid #000000;'><b> OT</b></td></tr>");
}
string strTeam1Row = "<tr><td style='border-right: 1px solid #000000;border-bottom: 1px solid #000000;'><b> " + strTeam1 + "</b></td>";
string strTeam2Row = "<tr><td style='border-right: 1px solid #000000;'><b> " + strTeam2 + "</b></td>";
string QTRfinal = "";
if (Qtrno == 9)
{
QTRfinal = "F";
}
else
{
QTRfinal = "OT";
}
for (int j = 0; j < dtTeam.Rows.Count; j++)
{
if (dtTeam.Rows[j]["QTR"].ToString() != QTRfinal)
{
if (dtTeam.Columns[1].ColumnName.ToString() == "Teamscore1")
{
strTeam1Row = strTeam1Row + "<td style='border-right: 1px solid #000000;border-bottom: 1px solid #000000;'> " + dtTeam.Rows[j]["Teamscore1"].ToString() + "</td>";
}
if (dtTeam.Columns[2].ColumnName.ToString() == "Teamscore2")
{
strTeam2Row = strTeam2Row + "<td style='border-right: 1px solid #000000;'> " + dtTeam.Rows[j]["Teamscore2"].ToString() + "</td>";
}
}
else
{
if (dtTeam.Columns[1].ColumnName.ToString() == "Teamscore1")
{
strTeam1Row = strTeam1Row + "<td style='border-bottom: 1px solid #000000;'> " + dtTeam.Rows[j]["Teamscore1"].ToString() + "</td>";
}
if (dtTeam.Columns[2].ColumnName.ToString() == "Teamscore2")
{
strTeam2Row = strTeam2Row + "<td > " + dtTeam.Rows[j]["Teamscore2"].ToString() + "</td>";
}
}
}
//strTeam1Row = strTeam1Row + "<td style='border-bottom: 1px solid #000000;'> " + dtTeam.Rows[0]["Teamscore1"].ToString() + "</td></tr>";
//strTeam2Row = strTeam2Row + "<td> " + dtTeam.Rows[0]["Teamscore2"].ToString() + "</td></tr>";
//for (int T = 0; T < dtTeamscoreDB.Rows.Count; T++)
//{
// if (dtTeam.Rows[T]["interval_name"].ToString().ToUpper() == "OT")
// {
// }
// //else
// //{
// // strTeam1Row = strTeam1Row + "<td style='border-right:1px solid #000000'> </td></tr>";
// // strTeam2Row = strTeam2Row + "<td> </td></tr>";
// //}
//}
strTable.Append(strTeam1Row);
strTable.Append(strTeam2Row);
for (int T = 0; T < dtTeamscoreDB.Rows.Count; T++)
{
if (dtTeamscoreDB.Rows[T]["notes"].ToString() != " " || dtTeamscoreDB.Rows[T]["notes"].ToString() !=null)
{
int interval_id = Convert.ToInt32(dtTeamscoreDB.Rows[T]["interval_id"].ToString());
if (dtTeamscoreDB.Rows[T]["interval_name"].ToString() != "OT")
{
if (Qtrno == 9)
{
if (dtTeamscoreDB.Rows[T]["interval_name"].ToString() == "F")
{
strnotes = strnotes + "F" + " : " + dtTeamscoreDB.Rows[T]["notes"].ToString() + "<br/>";
}
else
{
strnotes = strnotes + "Inn " + interval_id + ": " + dtTeamscoreDB.Rows[T]["notes"].ToString() + "<br/>";
}
}
else
{
if (Quater == "Q")
strnotes = strnotes + "Qtr " + interval_id + ": " + dtTeamscoreDB.Rows[T]["notes"].ToString() + "<br/>";
else
strnotes = strnotes + "Game " + interval_id + ": " + dtTeamscoreDB.Rows[T]["notes"].ToString() + "<br/>";
}
}
else
{
if (Qtrno == 9)
{
strnotes = strnotes + "Extra: " + dtTeamscoreDB.Rows[T]["notes"].ToString() + "<br/>";
}
else
{
strnotes = strnotes + "OT: " + dtTeamscoreDB.Rows[T]["notes"].ToString() + "<br/>";
}
}
}
}
strTable.Append("</table></td></td>");
strTable.Append("<tr><td colspan='2'> </td></tr>");
strTable.Append("<tr><td colspan='2' style='border: 1px solid #000000;'><b> Notes:</b></td></tr>");
strTable.Append("<tr><td colspan='2' style='border-left: 1px solid #000000;border-right: 1px solid #000000;border-bottom: 1px solid #000000;'>" + strnotes + "</td></tr></table><br/></pre>");
strTable.Append("<table><tr><td style='Font-Size:10px; align:center; color:Red;'>We want to thank our generous sponsors for supporting us and making this event possible.</td></tr>");
strTable.Append("<tr><td align='center'><img src='" + strimageurl + "' alt='Our Partners' /></td></tr></table>");
return strTable;
}
catch (Exception ex)
{
throw ex;
}
}
public static bool sendmailMultipleuser(string strFromEmailid, string strToEmailid, string strSubject, string strMessage)
{
bool mailFlag = false;
try
{
SmtpClient smtpclient = new SmtpClient();
//EncryptedUid = ObjUtility.EncryptString(Userid);
MailAddress FromUser = new MailAddress(strFromEmailid);
//MailAddress ToUser = new MailAddress(strToEmailid);
MailMessage Mailmsg = new MailMessage();
Mailmsg.From = FromUser;
string[] Toemailid = strToEmailid.Split(',');
for (int i = 0; i < Toemailid.Length; i++)
{
Mailmsg.To.Add(Toemailid[i].ToString());
}
Mailmsg.Subject = strSubject;
Mailmsg.IsBodyHtml = true;
Mailmsg.Body = strMessage;
smtpclient.Send(Mailmsg);
mailFlag = true;
return mailFlag;
}
catch
{
return mailFlag;
}
}
我创建的上述代码用于动态创建消息并通过电子邮件发送该消息。请帮我。