将aspx页面保存为jpeg并将其作为电子邮件发送到c#

时间:2012-09-13 06:11:11

标签: c# asp.net email jpeg

我的aspx页面有一个证书图像,我可以输入名称主题和成绩。我想以jpeg格式发送此aspx页面作为邮件正文。因此,当邮件接收者收到邮件时,他应该能够查看证书并下载它。请帮忙。

这是我的aspx页面

<body id="bdy">
    <div style="background-image: url('http://localhost:5520/Images/certi3.jpg'); background-repeat: no-repeat; background-position: center center; background-color: #FFFFFF; border: medium solid #000000; z-index: 1; top: 64px; position: absolute; height: 474px; width: 674px; left: 177px">
        <form id="form1" runat="server">
        <asp:TextBox id="TextBox1" runat="server" forecolor="#99CCFF" text="Name" style="z-index: 1; left: 171px; top: 228px; position: absolute; width: 330px"></asp:TextBox>
        <asp:TextBox id="TextBox2" runat="server" text="Date" style="z-index: 1; top: 282px; position: absolute; width: 148px; left: 361px; height: 17px"></asp:TextBox>
        <asp:TextBox id="TextBox3" runat="server" style="z-index: 1; left: 130px; top: 372px; position: absolute; width: 420px"></asp:TextBox>
        <asp:TextBox id="TextBox4" runat="server" style="z-index: 1; left: 227px; top: 282px; position: absolute; width: 62px; height: 17px"></asp:TextBox>
        <asp:button id="Button1" runat="server" style="z-index: 1; left: 251px; top: 488px; position: absolute; height: 26px" text="Save and Send " onclick="Button1_Click" />
        <asp:table id="Table1" runat="server" style="z-index: 1; top: 2px; position: absolute; height: 474px; width: 674px; left: 1px">
    </asp:table>
        </form>
    </div>
</body>

编辑1:获取aspx页面的html布局后,如何使用预生成的html发送和发送电子邮件?
以下是我的代码:

protected void Button1_Click(object sender, System.EventArgs e) 
{ 
    WebClient myClient = new WebClient(); 
    string myPageHTML = null; 
    byte[] requestHTML; 
    string currentPageUrl = Request.Url.ToString(); 
    UTF8Encoding utf8 = new UTF8Encoding(); 
    requestHTML = myClient.DownloadData(type the url); 
    myPageHTML = utf8.GetString(requestHTML); 
    Response.Write(myPageHTML); 
    SendMail();
}

1 个答案:

答案 0 :(得分:0)

有点不成熟,但你可以使用stringbuilder,只需将你的aspx代码附加到字符串构建器然后在发送你的MailMessage时只需添加字符串构建器变量作为mailmessage的主体