文本框未显示在asp.net中的.doc文件中

时间:2015-02-21 09:34:41

标签: html css

我有一些文本框,在发送电子邮件时没有显示在.doc文件中。请告诉我如何在doc中下载

我添加了aspx.cs和aspx代码

 <div id="design" runat="server" style="width:600px">
    <table border="0" id="rpt" runat="server" width="600">
        <tr>
            <td align="center" style="width: 100%; color: black; font-size: 12pt; font-family: Trebuchet MS;
                font-style: italic; background: #E4AFC1; height: 5px;white-space:nowrap">
                <b>Weekly Report for  <asp:Label ID="lblPro" runat="server"></asp:Label></b>
            </td>
        </tr>
        <tr>
            <td align="center" style="width: 100%; color: black; font-size: 14pt; font-family: Trebuchet MS;
                font-style: italic; background: #E4AFC1; height: 50px;">
                <h3>
                    <b><u>Offsite Optimization</u></b>
                </h3>
            </td>
        </tr>
        <tr>
            <td align="right" style="text-align: right; color: black; font-size: 10pt; font-family: Trebuchet MS;
                font-style: italic; background: #E4AFC1; height: 25px; width: 100%">
                <table style="width:20%" >

                    <tr>




                  <td style="width:200px"><div style="width:430px"></div></td>
                        <td>
                         <b> <asp:Label ID="sdate" runat="server" Font-Italic="true" ></asp:Label></b> 
                        </td>

                        <td class="style2">
                           <b>   To </b>
                        </td>
                        <td style="width:35px">
                         <b><asp:Label ID="endate" runat="server" Font-Italic="true"></asp:Label></b>   
                        </td>


                    </tr>

                </table>
            </td>
        </tr>
    </table>
    <table id="days" runat="server" width="600">
        <tr>
            <td class="side_heading" style="color: white; font-size: 10pt; font-family: Trebuchet MS;
                font-style: italic; background: #892D4D; height: 17.5pt; width: 100px;">
                Monday
            </td>


            <td>
                <input id="Text1" class="text" type="text" style=" font-size: 10pt; font-family:Trebuchet MS;font-style: italic; background: #F3F2F2; height: 17.5pt;" value="Social Bookmarking" />
            </td>
        </tr>
        <tr style="background-color:"#F1D7E0">
            <td class="side_heading" style="color: white; font-size: 10pt; font-family: Trebuchet MS;
                font-style: italic; background: #892D4D; height: 17.5pt;">
                Tuesday
            </td>
            <td>
                <input id="Text2" class="text" type="text" style=" font-size: 10pt; font-family:Trebuchet MS;font-style: italic; background: #F1D7E0; height: 17.5pt;" value="Submissions" />
            </td>
        </tr>
        <tr>
            <td class="side_heading" style="color: white; font-size: 10pt; font-family: Trebuchet MS;
                font-style: italic; background: #892D4D; height: 17.5pt;">
                Wednesday
            </td>
              <td>
                <input id="Text3" class="text" type="text" style=" font-size: 10pt; font-family:Trebuchet MS;font-style: italic; background: #DE9BB2; height: 17.5pt;" value="Article submissions" />
            </td>
        </tr>
        <tr>
            <td class="side_heading" style="color: white; font-size: 10pt; font-family: Trebuchet MS;
                font-style: italic; background: #892D4D; height: 17.5pt;">
                Thursday
            </td>
             <td>
                <input id="Text4" class="text" type="text" style=" font-size: 10pt; font-family:Trebuchet MS;font-style: italic; background: #DE9BB2; height: 17.5pt;" value="Submissions & blogs" />
            </td>
        </tr>
        <tr>
            <td class="side_heading" style="color: white; font-size: 10pt; font-family: Trebuchet MS;
                font-style: italic; background: #892D4D; height: 17.5pt;">
                Friday
            </td>
           <td>
                <input id="Text5" class="text" type="text" style=" font-size: 10pt; font-family:Trebuchet MS;font-style: italic; background: #DE9BB2; height: 17.5pt;" value="Link Building" />
            </td>
        </tr>
        <tr>
            <td class="side_heading" style="color: white; font-size: 10pt; font-family: Trebuchet MS;
                font-style: italic; background: #892D4D; height: 17.5pt;">
                Saturday
            </td>
            <td>
                <input id="Text6" class="text" type="text" style=" font-size: 10pt; font-family:Trebuchet MS;font-style: italic; background: #F1D7E0; height: 17.5pt;" value="Social Networking" />
            </td>
        </tr>
    </table>
    <br />
    <br />
    <table id="GRank" runat="server" width="600">
        <tr>
            <%--<td align="center" style="color: black; font-size: 12pt; font-family: Trebuchet MS;
                font-style: italic; background: #CF6DA4; width:20% " class="style1">
               Alexa Rank 
            </td>--%>

            <td align="center" style="color: black; font-size: 12pt; font-family: Trebuchet MS;
                font-style: italic; background: #CF6DA4;width:20% " class="style1">
             Visits
            </td>

             <td align="center" style="color: black; font-size: 12pt; font-family: Trebuchet MS;
                font-style: italic; background: #CF6DA4;width:20% " class="style1">
             Unique Visitors
            </td>

              <td align="center" style="color: black; font-size: 12pt; font-family: Trebuchet MS;
                font-style: italic; background: #CF6DA4;width:20% " class="style1">
            Average Time on Page
            </td>


              <td align="center" style="color: black; font-size: 12pt; font-family: Trebuchet MS;
                font-style: italic; background: #CF6DA4;width:20% " class="style1">
            Bounce Rate
            </td>
        </tr>
        <tr>
            <%--<td align="right" style="color: black; font-size: 12pt; font-family: Trebuchet MS;
                font-style: italic; font-weight: bold; background: #F3DAE8; height: 35px; width: 20px;">
                <img src="Images/global.jpg" />
            </td>--%>
          <%--  <td class="sub_text" style="color: black; font-size: 12pt; font-family: Trebuchet MS;
                font-style: italic; font-weight: bold; background: #F3DAE8; height: 35px;width:55px">
                <asp:Label ID="lblGRank" runat="server" Text='<%# Eval("GlobalRank") %>'></asp:Label>
            </td>--%>
            <td class="sub_text" style="color: black; font-size: 12pt; font-family: Trebuchet MS;
                font-style: italic; font-weight: bold; background: #F3DAE8; height: 35px; text-align:center">
                <asp:Label ID="LblVisits" runat="server" Text=''></asp:Label>
            </td>
            <td class="sub_text" style="color: black; font-size: 12pt; font-family: Trebuchet MS;
                font-style: italic; font-weight: bold; background: #F3DAE8; height: 35px; text-align:center">
                <asp:Label ID="LblUVisits" runat="server" Text=''></asp:Label>
            </td>
            <td class="sub_text" style="color: black; font-size: 12pt; font-family: Trebuchet MS;
                font-style: italic; font-weight: bold; background: #F3DAE8; height: 35px; text-align:center">
                <asp:Label ID="LblAvgTime" runat="server" Text=''></asp:Label>
            </td>
            <td class="sub_text" style="color: black; font-size: 12pt; font-family: Trebuchet MS;
                font-style: italic; font-weight: bold; background: #F3DAE8; height: 35px; text-align:center">
                <asp:Label ID="LblBounceRate" runat="server" Text=''></asp:Label>
            </td>
        </tr>
    </table>
    <br />
    <br />


    <br />
    <br />
    <asp:Repeater ID="Grdv_Report" runat="server">
        <%--<asp:GridView ID="Grdv_Report" runat="server" AutoGenerateColumns="false">--%>
        <HeaderTemplate>
            <table width="600">
                <tr>
                    <td align="center" style="color: black; font-size: 12pt; font-family: Trebuchet MS;
                        font-style: italic; background: #CF6DA4; height: 35px; width: 100%;">
                        Google Positions
                    </td>
                </tr>
                <tr>
                    <td>
                        <table width="600">
                            <tr>
                                <td align="center" style="color: black; font-size: 10pt; font-family: Trebuchet MS;
                                    font-style: italic; font-weight: bold; background: #EECDD9; height: 35px; width: 100px;">
                                    Keyword
                                </td>
                                <td align="center" style="color: black; font-size: 10pt; font-family: Trebuchet MS;
                                    font-style: italic; font-weight: bold; background: #EECDD9; height: 35px; width: 80px;">
                                    <asp:Label ID="LblMondy" runat="server" Text="Monday"></asp:Label>
                                </td>
                                <td align="center" style="color: black; font-size: 10pt; font-family: Trebuchet MS;
                                    font-style: italic; font-weight: bold; background: #EECDD9; height: 35px; width: 80px;">
                                    <asp:Label ID="LblTuesdy" runat="server" Text="Tuesday"></asp:Label>
                                </td>
                                <td align="center" style="color: black; font-size: 10pt; font-family: Trebuchet MS;
                                    font-style: italic; font-weight: bold; background: #EECDD9; height: 35px; width: 80px;">
                                    <asp:Label ID="LblWednes" runat="server" Text="Wednesday"></asp:Label>
                                </td>
                                <td align="center" style="color: black; font-size: 10pt; font-family: Trebuchet MS;
                                    font-style: italic; font-weight: bold; background: #EECDD9; height: 35px; width: 80px;">
                                    <asp:Label ID="LblThursdy" runat="server" Text="Thursday"></asp:Label>
                                </td>
                                <td align="center" style="color: black; font-size: 10pt; font-family: Trebuchet MS;
                                    font-style: italic; font-weight: bold; background: #EECDD9; height: 35px; width: 80px;">
                                    <asp:Label ID="LblFridy" runat="server" Text="Friday"></asp:Label>
                                </td>
                                <td align="center" style="color: black; font-size: 10pt; font-family: Trebuchet MS;
                                    font-style: italic; font-weight: bold; background: #EECDD9; height: 35px; width: 82px;">
                                    <asp:Label ID="LblSaturdy" runat="server" Text="Saturday"></asp:Label>
                                </td>
                            </tr>
        </HeaderTemplate>
        <ItemTemplate>
            <tr>
                <td align="left" style="color: black; font-size: 10pt; font-family: Trebuchet MS;
                    font-style: italic; font-weight: bold; background: #DE9BB2; height: 35px;">
                    <asp:Label ID="lblKey" runat="server" Text='<%# Eval("KeyWord") %>'></asp:Label>
                </td>
                <td align="center" style="color: black; font-size: 10pt; font-family: Trebuchet MS;
                    font-style: italic; font-weight: bold; background: #DE9BB2; height: 35px;">
                    <asp:Label ID="lblPos" runat="server" Text='<%# Eval("Monday") %>'></asp:Label>
                </td>
                <td align="center" style="color: black; font-size: 10pt; font-family: Trebuchet MS;
                    font-style: italic; font-weight: bold; background: #DE9BB2; height: 35px;">
                    <asp:Label ID="lblTues" runat="server" Text='<%# Eval("Tuesday") %>'></asp:Label>
                </td>
                <td align="center" style="color: black; font-size: 10pt; font-family: Trebuchet MS;
                    font-style: italic; font-weight: bold; background: #DE9BB2; height: 35px;">
                    <asp:Label ID="lblWed" runat="server" Text='<%# Eval("Wednesday") %>'></asp:Label>
                </td>
                <td align="center" style="color: black; font-size: 10pt; font-family: Trebuchet MS;
                    font-style: italic; font-weight: bold; background: #DE9BB2; height: 35px;">
                    <asp:Label ID="lblThurs" runat="server" Text='<%# Eval("Thursday") %>'></asp:Label>
                </td>
                <td align="center" style="color: black; font-size: 10pt; font-family: Trebuchet MS;
                    font-style: italic; font-weight: bold; background: #DE9BB2; height: 35px;">
                    <asp:Label ID="lblFri" runat="server" Text='<%# Eval("Friday") %>'></asp:Label>
                </td>
                <td align="center" style="color: black; font-size: 10pt; font-family: Trebuchet MS;
                    font-style: italic; font-weight: bold; background: #DE9BB2; height: 35px;">
                    <asp:Label ID="lblSat" runat="server" Text='<%# Eval("Saturday") %>'></asp:Label>
                </td>
            </tr>
        </ItemTemplate>
        <FooterTemplate>
            </table></td> </tr> </table>
        </FooterTemplate>
        <%-- </asp:GridView>--%>
    </asp:Repeater>
</div>

aspx.cs

 try
        {
            if (Session["Projectname"] != null && Session["Projectname"].ToString() != string.Empty)
            {

                string Projname = Session["Projectname"].ToString();
                System.IO.StringWriter stringWrite = new System.IO.StringWriter();
                System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);

                design.RenderControl(htmlWrite);

                string strBuilder = stringWrite.ToString();
                string strPath = Request.PhysicalApplicationPath + "\\Temp\\WeeklyReport of " + Projname + ".doc";

                LblNoteMsg.Text = strPath;
                if (File.Exists(strPath))
                {
                    var counter = 1;
                    strPath = strPath.Replace(".doc", " (" + counter + ").doc");
                    while (File.Exists(strPath))
                    {
                        strPath = strPath.Replace("(" + counter + ").doc", "(" + (counter + 1) + ").doc");
                        counter++;
                    }
                }
                using (var fStream = File.Create(strPath))
                {

                    fStream.Close();
                    fStream.Dispose();

                }
                 using(StreamWriter sWriter = new StreamWriter(strPath))
                   {
                sWriter.Write(strBuilder);
                sWriter.Close();
                sWriter.Dispose();
                Response.Clear();
                   }
                DateTime input = DateTime.Now;
                int delta = DayOfWeek.Monday - input.DayOfWeek;
                DateTime dats = DateTime.Now.AddDays(delta);
                //this week
                DateTime monday = input.AddDays(delta);
                string MonDate = monday.ToShortDateString();
                DateTime sat = monday.AddDays(5);
                string SatDate = sat.ToShortDateString();
                StreamReader r = new StreamReader(Server.MapPath("~/WeeklyMail.txt"));
                string body = r.ReadToEnd();
                MailMessage Msg = new MailMessage();
                string MailId = txtMailId.Text;
                foreach (string ss in MailId.Split(",".ToCharArray()))
                {
                    if (string.IsNullOrEmpty(ss) == false)
                    {
                        Msg.To.Add(new MailAddress(ss));
                    }
                }
                Msg.Bcc.Add(new MailAddress("support@sunlightit.com"));
                body = body.Replace("<%MonDate%>", MonDate);
                body = body.Replace("<%SatDate%>", SatDate);
                Msg.Subject = "Weekly status Report of " + Projname + "," + DateTime.Now.ToShortDateString() + "";
                Msg.Body = body;
                Msg.IsBodyHtml = true;
                Msg.Attachments.Add(new Attachment(strPath));
             //   File.Delete(strPath);
                SmtpClient MailServer = new SmtpClient();
                try
                {
                    MailServer.Send(Msg);
                    string reply = (Msg.DeliveryNotificationOptions = System.Net.Mail.DeliveryNotificationOptions.OnSuccess).ToString();


                    if (reply == "OnSuccess")
                    {
                        txtMailId.Text = "";
                        tblMail.Visible = false;
                        lblMsg.ForeColor = System.Drawing.Color.Green;
                        lblMsg.Text = "Mail has send succesfully";
                    }
                    else
                    {
                        lblMsg.ForeColor = System.Drawing.Color.Red;
                        lblMsg.Text = "Mail delivery unsuccessfull";
                    }

                }
  • 它在网页中正确显示但没有进入.doc文件

enter image description here

enter image description here

0 个答案:

没有答案