0
<div class="popup-holder">
            <div class="popup-frame">
                <div class="container">
                    <div class="mail-block">
                        <div class="mail-holder">
                            <strong class="mail-logo"><a href="#">abc website</a></strong>
                            <div class="mail-page">
                                <div class="mail-page-holder">
                                    <div class="mail-page-frame">
                                        <p>Hello &lt;<asp:Label ID="lblfriend" runat="server" Text="Label"></asp:Label>>!,</p>
                                        <p>Great News!  &lt;One of your FB Friends/<asp:Label ID="lblmyname" runat="server" Text="Label"></asp:Label>>  has invited you to BlissLink.</p>
                                        <p>(<asp:Label ID="lblmyname1" runat="server" Text="Label"></asp:Label>) says:  &lt;<asp:Label
                                            ID="lblmess" runat="server" Text="abc is fun ,"></asp:Label>><br /><br /></p>
                                        <p></p>
                                        <ul class="f-list">
                                            <li>
                                                <asp:Image ID="Image3" runat="server" width="48" height="48" />
                                                <strong class="title"><span><asp:Label ID="Label2" runat="server" ></asp:Label></span></strong>
                                            </li>
                                            <li>
                                                <asp:Image ID="Image4" runat="server" width="48" height="48" />
                                                <strong class="title"><span> 
                                                    <asp:Label ID="Label3" runat="server" ></asp:Label></span></strong>
                                            </li>
                                            <li>
                                                <asp:Image ID="Image5" runat="server" width="48" height="48" />
                                                <strong class="title"><span><asp:Label ID="Label4" runat="server" ></asp:Label></span></strong>
                                            </li>
                                            <li>
                                                <asp:Image ID="Image6" runat="server" width="48" height="48" />
                                                <strong class="title"><span><asp:Label ID="Label5" runat="server" ></asp:Label></span></strong>
                                            </li>
                                            <li>
                                                <asp:Image ID="Image7" runat="server" width="48" height="48" />
                                                <strong class="title"><span> <asp:Label ID="Label6" runat="server"></asp:Label></span></strong>
                                            </li>
                                            <li>
                                                <asp:Image ID="Image8" runat="server" width="48" height="48" />
                                                <strong class="title"><span> <asp:Label ID="Label7" runat="server" ></asp:Label></span></strong>
                                            </li>
                                            <li>
                                                <asp:Image ID="Image9" runat="server" width="48" height="48" />
                                                <strong class="title"><span><asp:Label ID="Label8" runat="server" ></asp:Label></span></strong>
                                            </li>
                                            <li>
                                                <asp:Image ID="Image10" runat="server" width="48" height="48" />
                                                <strong class="title"><span> <asp:Label ID="Label9" runat="server" ></asp:Label></span></strong>
                                            </li>
                                            <li>
                                                <asp:Image ID="Image11" runat="server" width="48" height="48" />
                                                <strong class="title"><span><asp:Label ID="Label10" runat="server" ></asp:Label></span></strong>
                                            </li>
                                            <li>
                                                <asp:Image ID="Image12" runat="server" width="48" height="48" />
                                                <strong class="title"><span><asp:Label ID="Label11" runat="server" ></asp:Label></span></strong>
                                            </li>
                                        </ul>
                                        <asp:Button ID="Button6" runat="server" Text="Expand Your Network"  CssClass="btn" />
                                        <span class="bot-text">Cheers,<br />Your abc Team</span>
                                    </div>
                                </div>
                            </div>
                            <span class="un">If you have no more interest in receiving our news, <a href="#">unsubscribe.</a></span>
                        </div>
                    </div>
                </div>
            </div>
        </div>

这些图像是在运行时决定的,是否将其嵌入到电子邮件正文中

请帮忙

4

3 回答 3

6

如果您只想要电子邮件中的那部分标记,则将其放在用户控件 (myEmailControl.ascx) 中。然后,您可以从发送电子邮件的脚本中调用控件上的 Render() 并拦截控件的 html 输出。然后,您可以将该 html 放入电子邮件正文中。(您的图片还需要绝对网址,以便它们显示在电子邮件中,但我相信您已经想到了这一点)

发送电子邮件的页面/处理程序:

    StringBuilder htmlResponse = new StringBuilder();
    using (StringWriter sw = new StringWriter(htmlResponse))
    {
        using (HtmlTextWriter textWriter = new HtmlTextWriter(sw))
        {
            Control emailBody = Page.LoadControl("myEmailControl.ascx");
            emailBody.RenderControl(textWriter);
        }
    }
    string emailHtml = htmlResponse.ToString();
于 2012-04-05T18:35:34.163 回答
3

您可以从页面下载呈现的 HTML 并将其发送:

WebRequest request = WebRequest.Create("http://server.com/path/to/page.aspx");
WebResponse response = request.GetResponse();

StringReader reader = new StringReader(response.GetResponseStream());

string html = reader.ReadToEnd();

现在您只需发送html电子邮件中的内容即可。

于 2012-04-05T18:27:38.550 回答
0

您最好的选择可能是将图像输出为 HTML 中的 Base 64。

<img src="data:image/png;base64,iVBrkJggg==" alt="Base 64 encoded!" /> 

在您后面的代码中,获取图像,将其转换为 Base 64 并将其打印为 src!

于 2012-04-05T18:29:10.883 回答