简体   繁体   English

程序化电子邮件图像随机调整大小(aspx / vb)

[英]Programmatic Email Image Randomly Resizes (aspx/vb)

I am sending out emails to my Outlook inbox Programmatically via VB.net. 我正在通过VB.net以编程方式向我的Outlook收件箱发送电子邮件。

A part of my email is being added through a div in my aspx, as you can see in the div's code I have pasted, there's an image I am attaching on the right hand cell of the div, it seems when I open the email, the image randomly changes between to sizes when I re open the email. 我的电子邮件的一部分是通过aspx中的div添加的,正如您在粘贴的div的代码中所看到的那样,在div的右手边有一个图像,似乎是在打开电子邮件时,当我重新打开电子邮件时,图像会随机变化为大小。

I tried attaching my image direct from vb but I encounter the same problem. 我尝试直接从vb附加图像,但是遇到相同的问题。

I was wondering if anyone had any suggestions or advice for my problem. 我想知道是否有人对我的问题有任何建议或意见。

Here is my aspx for the div: 这是我的div的aspx:

    <div id="div2" runat="server" class="div1">
                    <table id="TABLE3" cellpadding="0" cellspacing="0" style="font-family: Verdana" width="100%" class="auto-style14">
                        <tr>                              
                            <td style="font-size: 10pt; text-align: right" class="auto-style16">
                                <asp:Image ID="ImageButton1" runat="server" ImageUrl="~/icons/Logo.bmp" ImageAlign="Right" Height="40%" Width="40%" />
                                <br />
                            </td>
                        </tr>
                    </table>
                </div>

Here is my vb that attaches the div to the email: 这是我的vb,将div附加到电子邮件:

   Dim sb2 As StringBuilder = New StringBuilder
            Dim sw2 As StringWriter = New StringWriter(sb2)
            Dim htw2 As HtmlTextWriter = New HtmlTextWriter(sw2)
            div2.RenderControl(htw2)

.

     .Body += sb2.ToString() + "<br />"

Thank you in advance. 先感谢您。

If you are trying to add controls to a html string that is going to an unknown location then it is best not to add Dynamic values for the height and width. 如果您试图将控件添加到将要到达未知位置的html字符串中,那么最好不要为高度和宽度添加动态值。

You should set the height and with to a static value ie 50px 您应该将height设置为一个静态值,即50px

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM