在下面的html页面中出现错误.... [英] getting error in the below html page....

查看:75
本文介绍了在下面的html页面中出现错误....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public class SendMail
    {
        public int SendeMail(string company, string empcode, string fromaddress, string toaddress, string subject, string detail, string operation, string username)
        {
            Library lib = new Library();
            int sEmailSend = 0;
            try
            {
                MailMessage objMailMessage = new MailMessage();
                objMailMessage.To.Add(toaddress);
                objMailMessage.From = new MailAddress(fromaddress);
                objMailMessage.Subject = subject;
                objMailMessage.Body = "<center>";
                objMailMessage.Body +="<div>";
                objMailMessage.Body +="<table>";
                objMailMessage.Body+="<tr>";
                objMailMessage.Body+="<td>";
                objMailMessage.Body+="<u>SLIMITED<br/>";
                objMailMessage.Body+="RANAVAV</u>";
                objMailMessage.Body+="</td>";
                objMailMessage.Body+="</tr>";
                objMailMessage.Body+="</table>";
                objMailMessage.Body+="</div>";
                objMailMessage.Body += "</center>";
                objMailMessage.Body+="<br />";
                objMailMessage.Body += "<table>";
                objMailMessage.Body += "<tr >";
                objMailMessage.Body += "<td align="right" style="width: 600px">";
                objMailMessage.Body += "<asp:Label ID="lblEmpCode" CssClass="lbl" runat="server"  Width="113px">Employee No.</asp:Label>";
                objMailMessage.Body += "</td>";
                objMailMessage.Body += "<td  align="left" valign="top" style="width: 110px">";
                objMailMessage.Body += "<asp:Label ID="txtEmpCode" CssClass="lblBoldBlue"  runat="server">";
                objMailMessage.Body +="<table>";
                objMailMessage.Body +="<tr>";
                objMailMessage.Body +="<td>";
                objMailMessage.Body +="To,<br/>";
                objMailMessage.Body +="Personal Department<br />";
                objMailMessage.Body +="SLimited<br />";
                objMailMessage.Body +="Rav";
                objMailMessage.Body +="</td>";
                objMailMessage.Body +="</tr>";
                objMailMessage.Body +="</table>";
                objMailMessage.Body +="<br /><br />";

                objMailMessage.Body +="<table>";
                objMailMessage.Body +="<tr>";
                objMailMessage.Body +="<td>";
                objMailMessage.Body +="Dear Sir,";
                objMailMessage.Body +="</td>";
                objMailMessage.Body +="</tr>";
                objMailMessage.Body +="</table>";
                objMailMessage.Body +="<center>";
                objMailMessage.Body +="<table>";
                objMailMessage.Body +="<tr>";
                objMailMessage.Body +="<td>";
                objMailMessage.Body +="Sub:<u>Application for Reimbursement of Medical Expenses</u>";
                objMailMessage.Body +="</td>";
                objMailMessage.Body +="</tr>";
                objMailMessage.Body +="</table>";
                objMailMessage.Body +="</center>";
                objMailMessage.Body +="</asp:Label>";
                objMailMessage.Body +="</td>";
                objMailMessage.Body +="</tr>";
                objMailMessage.Body +="</table>";
                objMailMessage.Body +="<br />";
                objMailMessage.Body +="<table>";
                objMailMessage.Body +="<tr>";
                objMailMessage.Body +="<td>";
                objMailMessage.Body +="I,the undersigned,hereby certify that i have incurred an expense of Rs. <asp:TextBox ID="txtUserName" runat="server" MaxLength="10"></asp:TextBox><br />";
                objMailMessage.Body +="&nbsp;(Rupees<asp:TextBox ID="TextBox1" runat="server" MaxLength="10"></asp:TextBox>)towards Medical Expenses on Account of <br />";
                objMailMessage.Body +="my/self dependant family - members during the period from<asp:TextBox ID="TextBox2" runat="server" MaxLength="10"></asp:TextBox>to<asp:TextBox ID="TextBox3" runat="server" MaxLength="10"></asp:TextBox><br />";
                objMailMessage.Body +="and - request that the same may be reimbursed to me under the Company's Medical Benefit<br />";
                objMailMessage.Body +="Scheme.<br />";
                objMailMessage.Body +="<br />";
                objMailMessage.Body +="<br />";
                objMailMessage.Body +="<br />";
                objMailMessage.Body +="<br />";
                objMailMessage.Body +="Thanking you,";
                objMailMessage.Body +="</td>";
                objMailMessage.Body +="</tr>";
                objMailMessage.Body +="</table><br />";
                objMailMessage.Body +="<br />";
                objMailMessage.Body +="<table>";
                objMailMessage.Body +="<tr>";
                objMailMessage.Body +="<td align="right" style="width: 491px">";
                objMailMessage.Body +="<asp:Label ID="lblsig" CssClass="lbl" runat="server"  Width="113px">Signature:</asp:Label>";
                objMailMessage.Body +="</td>";
                objMailMessage.Body +="<td  align="left" valign="top" style="width: 188px">";
                objMailMessage.Body +="<asp:Label ID="txtsig" CssClass="lblBoldBlue"  runat="server">";
                objMailMessage.Body +="</asp:Label>";
                objMailMessage.Body +="</td>";
                objMailMessage.Body +="</tr>";
                objMailMessage.Body +="</table>";
                objMailMessage.Body +="<table>";
                objMailMessage.Body +="<tr >";
                objMailMessage.Body +="<td align="right" style="width: 491px">";
                objMailMessage.Body +="<asp:Label ID="lblname" CssClass="lbl" runat="server"  Width="113px">name:</asp:Label>";
                objMailMessage.Body +="</td>";
                objMailMessage.Body +="<td  align="left" valign="top" style="width: 188px">";
                objMailMessage.Body +="<asp:Label ID="txtname" CssClass="lblBoldBlue"  runat="server">";
                objMailMessage.Body +="</asp:Label>";
                objMailMessage.Body +="</td>";
                objMailMessage.Body +="</tr>";
                objMailMessage.Body +="</table>";
                objMailMessage.Body +="<table>";
                objMailMessage.Body +="<tr >";
                objMailMessage.Body +="<td align="right" style="width: 491px">";
                objMailMessage.Body +="<asp:Label ID="lbldesignation" CssClass="lbl" runat="server"  Width="113px">Designation</asp:Label>";
                objMailMessage.Body +="</td>";
                objMailMessage.Body +="<td  align="left" valign="top" style="width: 188px">";
                objMailMessage.Body +="<asp:Label ID="txtdesignation" CssClass="lblBoldBlue"  runat="server">";
                objMailMessage.Body +="</asp:Label>";
                objMailMessage.Body +="</td>";
                objMailMessage.Body +="</tr>";
                objMailMessage.Body +="</table>";
                objMailMessage.Body +="<table>";
                objMailMessage.Body +="<tr>";
                objMailMessage.Body +="<td align="right" style="width: 491px">";
                objMailMessage.Body +="<asp:Label ID="lbldepartment" CssClass="lbl" runat="server"  Width="113px">Department</asp:Label>";
                objMailMessage.Body +="</td>";
                objMailMessage.Body +="<td  align="left" valign="top" style="width: 188px">";
                objMailMessage.Body +="<asp:Label ID="txtdepartment" CssClass="lblBoldBlue"  runat="server">";
                objMailMessage.Body +="</asp:Label>";
                objMailMessage.Body +="</td>";
                objMailMessage.Body +="</tr>";
                objMailMessage.Body +="</table>";
                objMailMessage.Body +="<table>";
                objMailMessage.Body +="<tr>";
                objMailMessage.Body +="<td align="left"  valign="top">";
                objMailMessage.Body +="<asp:Label ID="lblNotifiedDate" CssClass="lbl" runat="server" >Date</asp:Label></td>";
                objMailMessage.Body +="<td valign="top" align="left">";
                objMailMessage.Body +="<asp:TextBox ID="txtNotifiedDate" ReadOnly="true" CssClass="lbl"  runat="server" Width="103px"></asp:TextBox></td>";
                objMailMessage.Body +="</tr>";
                objMailMessage.Body +="</table>";



                objMailMessage.IsBodyHtml = true;
                string sSmtpIp = lib.getSmtpIp(company);
                string[] sSmtpIpArr = sSmtpIp.Split(',');
                string sIp = "";
                int iPort = 0;
                if (sSmtpIpArr.Length == 2)
                {
                    sIp = Convert.ToString(sSmtpIpArr[0]);
                    iPort = Convert.ToInt32(sSmtpIpArr[1]);
                }

                SmtpClient objSmtp = new SmtpClient(sIp, iPort);
                objSmtp.Send(objMailMessage);
                sEmailSend = 1;
            }
            catch (Exception ex)
            {
                sEmailSend = 0;
            }
            return sEmailSend;
        }



编辑TR:您的问题是什么?



Edit TR: What''s your question?

推荐答案

您在字符串中使用了:

示例:
You use " inside your strings:

Example:
objMailMessage.Body +="<asp:Label ID="lblname" CssClass="lbl" runat="server" Width="113px">name:</asp:Label>";




根本不可能,只需将其替换为''

像这样:




This is simply not possible, just replace them with ''

like this:

objMailMessage.Body +="<asp:Label ID='lblname' CssClass='lbl' Width='113px'>name:</asp:Label>



我也不太确定电子邮件是否支持ASP代码-_-



I''m also not too sure if an e-mail will support ASP code -_-


这篇关于在下面的html页面中出现错误....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆