.net 通过电子邮件发送页面ViewState问题

.net 通过电子邮件发送页面ViewState问题,.net,email,viewstate,.net,Email,Viewstate,我的客户想要一个页面,他们可以通过IE将其作为电子邮件发送,但当我执行文件>发送>逐页电子邮件时,它会在页面顶部添加一个隐藏的输入字段,其中包含一些随机字母 我被要求移除它 我尝试过EnableViewState=false,并用javascript将其从dom中删除,甚至用CSS将其隐藏,但它仍然会显示在电子邮件中(但不会显示在浏览器的页面上):( 我不知道您可能需要什么帮助,所以我将全部粘贴,以下是代码: cs: using System; using System.Collections.

我的客户想要一个页面,他们可以通过IE将其作为电子邮件发送,但当我执行文件>发送>逐页电子邮件时,它会在页面顶部添加一个隐藏的输入字段,其中包含一些随机字母

我被要求移除它

我尝试过EnableViewState=false,并用javascript将其从dom中删除,甚至用CSS将其隐藏,但它仍然会显示在电子邮件中(但不会显示在浏览器的页面上):(

我不知道您可能需要什么帮助,所以我将全部粘贴,以下是代码:

cs:

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WorksUnit.Clydesdale.PropertyManager;
using WorksUnit.Clydesdale.PropertyManager.BusinessObjects;

namespace WorksUnit.Clydesdale.PropertyManager.Website.Summary
{
    public partial class MaintenanceJobSheet : System.Web.UI.Page
    {
        private int _cachedPropertyId = 0;
        private const string PROPERTYID_QUERY_STRING = "PropertyID";
        private int _propertyId
        {
            get
            {
                if (_cachedPropertyId == 0 && Request.QueryString[PROPERTYID_QUERY_STRING] != null)
                {
                    int.TryParse(Request.QueryString[PROPERTYID_QUERY_STRING].ToString(), out _cachedPropertyId);
                }

                return _cachedPropertyId;
            }
            set { _cachedPropertyId = value; }
        }
        private int maintenanceId
        {
            get
            {
                if (!string.IsNullOrEmpty(Request.QueryString["maintenanceId"]))
                {
                    return Convert.ToInt32(Request.QueryString["maintenanceId"]);
                }
                else
                {
                    return 0;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (maintenanceId != 0)
            {
                BusinessObjects.Maintenance maintenance = BusinessObjects.Maintenance.Retrieve(maintenanceId);
                LiteralJobNumber.Text = maintenance.JobNumber;
                LiteralDescription.Text = maintenance.Description;
                LiteralContractor.Text = maintenance.Contractor.Description;
                if(maintenance.Date!=DateTime.MinValue)
                {
                    LiteralDate.Text = maintenance.Date.ToShortDateString();
                }
                if(maintenance.CompletionDate!=DateTime.MinValue)
                {
                    LiteralCompletionDate.Text = maintenance.CompletionDate.ToShortDateString();
                }
                if(maintenance.DateInvoiced!=DateTime.MinValue)
                {
                    LiteralInvoicedDate.Text = maintenance.DateInvoiced.ToShortDateString();
                }
                if(maintenance.DatePaid!=DateTime.MinValue)
                {
                    LiteralDatePaid.Text =maintenance.DatePaid.ToShortDateString();
                }
                LiteralChargeDetails.Text = maintenance.DetailsOfCharging;
                LiteralUpdate.Text = maintenance.LatestSummary;
            }
        }
    }
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MaintenanceJobSheet.aspx.cs" EnableViewState="false" Inherits="WorksUnit.Clydesdale.PropertyManager.Website.Summary.MaintenanceJobSheet" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Clydesdale Property Solutions Work Request</title>
    <link rel="stylesheet" type="text/css" media="screen" href="/css/screen.css" />
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <span><b>Contractor:</b>&nbsp;&nbsp;</span><asp:Literal ID="LiteralContractor" runat="server" />
        <br /><br />
        <span>Please undertake the following:-</span>
        <br /><br />
        <table width="600" cellpadding="3" cellspacing="0" border="1px">
        <tr>
            <td valign="top" width="150">Job Number:</td>            
            <td><asp:Literal ID="LiteralJobNumber" runat="server" Text="N/A" /></td>
        </tr>
        <tr>
            <td valign="top" width="150">Description:</td>            
            <td><asp:Literal ID="LiteralDescription" runat="server" /></td>
        </tr>
        <tr>
            <td valign="top" width="150">Date:</td>            
            <td><asp:Literal ID="LiteralDate" runat="server" /></td>
        </tr>
        <tr>
            <td valign="top" width="150">Completion Date:</td>
            <td><asp:Literal ID="LiteralCompletionDate" runat="server" /></td>
        </tr>        
        <tr>
            <td valign="top" width="150">Invoiced Date:</td>
            <td><asp:Literal ID="LiteralInvoicedDate" runat="server" /></td>
        </tr>
        <tr>
            <td valign="top" width="150">Date Paid:</td>
            <td><asp:Literal ID="LiteralDatePaid" runat="server" /></td>
        </tr>
        <tr>
            <td valign="top" width="150">Details of Charging:</td>
            <td><asp:Literal ID="LiteralChargeDetails" runat="server" /></td>
        </tr>
        <tr>
            <td valign="top" width="150">Update:</td>
            <td><asp:Literal ID="LiteralUpdate" runat="server" /></td>
        </tr>
        </table>
        <br /><br /><br />
        <span>Thank You</span>
        <br /><br /><br />
        Clydesdale Estates,<br />
        Tel:02380331234 <br />
        Fax:02380335522<br />
        Email: info@clydesdale-estates.co.uk
    </div>
    </form>
</body>
</html>
前端:

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WorksUnit.Clydesdale.PropertyManager;
using WorksUnit.Clydesdale.PropertyManager.BusinessObjects;

namespace WorksUnit.Clydesdale.PropertyManager.Website.Summary
{
    public partial class MaintenanceJobSheet : System.Web.UI.Page
    {
        private int _cachedPropertyId = 0;
        private const string PROPERTYID_QUERY_STRING = "PropertyID";
        private int _propertyId
        {
            get
            {
                if (_cachedPropertyId == 0 && Request.QueryString[PROPERTYID_QUERY_STRING] != null)
                {
                    int.TryParse(Request.QueryString[PROPERTYID_QUERY_STRING].ToString(), out _cachedPropertyId);
                }

                return _cachedPropertyId;
            }
            set { _cachedPropertyId = value; }
        }
        private int maintenanceId
        {
            get
            {
                if (!string.IsNullOrEmpty(Request.QueryString["maintenanceId"]))
                {
                    return Convert.ToInt32(Request.QueryString["maintenanceId"]);
                }
                else
                {
                    return 0;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (maintenanceId != 0)
            {
                BusinessObjects.Maintenance maintenance = BusinessObjects.Maintenance.Retrieve(maintenanceId);
                LiteralJobNumber.Text = maintenance.JobNumber;
                LiteralDescription.Text = maintenance.Description;
                LiteralContractor.Text = maintenance.Contractor.Description;
                if(maintenance.Date!=DateTime.MinValue)
                {
                    LiteralDate.Text = maintenance.Date.ToShortDateString();
                }
                if(maintenance.CompletionDate!=DateTime.MinValue)
                {
                    LiteralCompletionDate.Text = maintenance.CompletionDate.ToShortDateString();
                }
                if(maintenance.DateInvoiced!=DateTime.MinValue)
                {
                    LiteralInvoicedDate.Text = maintenance.DateInvoiced.ToShortDateString();
                }
                if(maintenance.DatePaid!=DateTime.MinValue)
                {
                    LiteralDatePaid.Text =maintenance.DatePaid.ToShortDateString();
                }
                LiteralChargeDetails.Text = maintenance.DetailsOfCharging;
                LiteralUpdate.Text = maintenance.LatestSummary;
            }
        }
    }
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MaintenanceJobSheet.aspx.cs" EnableViewState="false" Inherits="WorksUnit.Clydesdale.PropertyManager.Website.Summary.MaintenanceJobSheet" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Clydesdale Property Solutions Work Request</title>
    <link rel="stylesheet" type="text/css" media="screen" href="/css/screen.css" />
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <span><b>Contractor:</b>&nbsp;&nbsp;</span><asp:Literal ID="LiteralContractor" runat="server" />
        <br /><br />
        <span>Please undertake the following:-</span>
        <br /><br />
        <table width="600" cellpadding="3" cellspacing="0" border="1px">
        <tr>
            <td valign="top" width="150">Job Number:</td>            
            <td><asp:Literal ID="LiteralJobNumber" runat="server" Text="N/A" /></td>
        </tr>
        <tr>
            <td valign="top" width="150">Description:</td>            
            <td><asp:Literal ID="LiteralDescription" runat="server" /></td>
        </tr>
        <tr>
            <td valign="top" width="150">Date:</td>            
            <td><asp:Literal ID="LiteralDate" runat="server" /></td>
        </tr>
        <tr>
            <td valign="top" width="150">Completion Date:</td>
            <td><asp:Literal ID="LiteralCompletionDate" runat="server" /></td>
        </tr>        
        <tr>
            <td valign="top" width="150">Invoiced Date:</td>
            <td><asp:Literal ID="LiteralInvoicedDate" runat="server" /></td>
        </tr>
        <tr>
            <td valign="top" width="150">Date Paid:</td>
            <td><asp:Literal ID="LiteralDatePaid" runat="server" /></td>
        </tr>
        <tr>
            <td valign="top" width="150">Details of Charging:</td>
            <td><asp:Literal ID="LiteralChargeDetails" runat="server" /></td>
        </tr>
        <tr>
            <td valign="top" width="150">Update:</td>
            <td><asp:Literal ID="LiteralUpdate" runat="server" /></td>
        </tr>
        </table>
        <br /><br /><br />
        <span>Thank You</span>
        <br /><br /><br />
        Clydesdale Estates,<br />
        Tel:02380331234 <br />
        Fax:02380335522<br />
        Email: info@clydesdale-estates.co.uk
    </div>
    </form>
</body>
</html>

Clydesdale物业解决方案工作请求
承包商:


请作出以下承诺:-

工作编号: 说明: 日期: 竣工日期: 开票日期: 支付日期: 收费详情: 更新:


非常感谢。


克莱德斯代尔庄园,
电话:02380331234
传真:02380335522
电邮:info@clydesdale-estates.co.uk
这就是我在电子邮件上查看源代码时显示的内容:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Clydesdale Property Solutions Work Request</TITLE>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<BASE href="http://localhost:4659/Summary/MaintenanceJobSheet.aspx">
<LINK rel=stylesheet type=text/css href="/css/screen.css" media=screen>
<META name=GENERATOR content="MSHTML 8.00.6001.18854">
</HEAD>
<BODY>
<FORM id=form1 method=post name=form1 action=MaintenanceJobSheet.aspx>
<!-- random input appears here (wrapped in a div) --><DIV>
<INPUT id=__VIEWSTATE 
value=/wEPDwUJNzAyODg3NjY4ZGT+zJss/Xlbkhlxv8we8oRPUGNy9Q== type=hidden name=__VIEWSTATE> 
</DIV> <!-- and ends here -->
<DIV><SPAN><B>Contractor:</B>&nbsp;&nbsp;</SPAN> <BR><BR><SPAN>Please undertake the following:-</SPAN> <BR><BR>
<TABLE border=1 cellSpacing=0 cellPadding=3 width=600>
<TD vAlign=top width=150><!-- more content goes here --></TD>
</TR>
</TABLE>
</DIV>
</FORM>
</BODY>
</HTML>

Clydesdale物业解决方案工作请求
承包商:

请承担以下义务:-


任何帮助都将不胜感激。

我遇到了一个类似的问题,我正在为我的雇主创建一封HTML新闻信,当我通过Internet Explorer/Outlook发送时,所有内部代码(图片、链接…)都发生了更改

我相信你的客户(和我一样)希望使用此功能,以便他们可以使用outlook编辑电子邮件并将其发送给outlook联系人。似乎没有很多方法可以解决此问题

到目前为止,我只找到了两种方法

  • 您可以使用不同的电子邮件客户端(如Mozilla的Thunderbird)。您可以将源代码复制并粘贴到电子邮件的源代码中,然后发送(尽管当您让其他人复制并粘贴时,这并不是一个完全专业的项目)

  • 或者另一种方法是,您可以使用其他语言的库(如PHP)创建自己的电子邮件服务

    当你通过PHP发送邮件时,一切都不会改变,你可以控制邮件的来源。这需要一些调整,这样邮件就不会像垃圾邮件一样被丢弃,但是如果你感兴趣的话,我在下面发布了一些代码

  • 如果其他人有更好的想法或更简单的方法,请告诉我,如果有更简单的方法,我将非常高兴。
    你几乎应该说去死吧,让它保持原样

    <?php 
    //file_get_contents('./newsletter.html', true); // or use a file for the body
    //$body = file_get_contents('../newsletter/2010/1/newsletter.html', true);
    //define the receiver of the email
    $to = 'someone@receiver.com';
    //define the subject of the email
    $subject = 'Test HTML email'; 
    //create a boundary string. It must be unique 
    //so we use the MD5 algorithm to generate a random hash
    $random_hash = md5(date('r', time())); 
    //define the headers we want passed. Note that they are separated with \r\n
    $headers = "From: you@yourEmail.com\r\nReply-To: you@yourEmail.com";
    //add boundary string and mime type specification
    $headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\""; 
    //define the body of the message.
    ob_start(); //Turn on output buffering
    ?>
    --PHP-alt-<?php echo $random_hash; ?>  
    Content-Type: text/plain; charset="iso-8859-1" 
    Content-Transfer-Encoding: 7bit
    
    Hello World!!! 
    This is simple text email message. 
    
    --PHP-alt-<?php echo $random_hash; ?>  
    Content-Type: text/html; charset="iso-8859-1" 
    Content-Transfer-Encoding: 7bit
    
    <h2>Hello World!</h2>
    <p>This is something with <b>HTML</b> formatting.</p>
    <img src="http://****/test.png" width="600" height="123" alt="test pic for html email">
    
    --PHP-alt-<?php echo $random_hash; ?>--
    <?
    //copy current buffer contents into $message variable and delete current output buffer
    $message = ob_get_clean();
    //send the email
    $mail_sent = @mail( $to, $subject, $message, $headers );
    //if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" 
    echo $mail_sent ? "Mail sent" : "Mail failed";
    ?>
    
    
    --PHP alt-
    内容类型:文本/普通;charset=“iso-8859-1”
    内容传输编码:7bit
    你好,世界!!!
    这是一封简单的短信。
    --PHP alt-
    内容类型:text/html;charset=“iso-8859-1”
    内容传输编码:7bit
    你好,世界!
    这是HTML格式的东西

    --PHP alt---