【问题标题】:How do I get rid of '=' symbols in the email output sent using VB.NET如何摆脱使用 VB.NET 发送的电子邮件输出中的“=”符号
【发布时间】:2015-05-20 10:41:41
【问题描述】:

我正在使用 VB.NET 从 ASP.NET 表单发送电子邮件。我正在使用一个文件夹作为电子邮件的目的地。不幸的是,我在消息正文的每一行末尾都看到了“=”符号。

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Try
            Dim mailMessage As New MailMessage()
            mailMessage.To.Add("someone@abc.com")
            mailMessage.From = New MailAddress("someone@abc.com")
            mailMessage.Subject = "Subject"
            mailMessage.Body = ("<br>The following query was generated at " + DateTime.Now_+ "<br/><br/>Name : " + TextBox1.Text + "<br/><br/>Email : " + TextBox2.Text + "<br/><br/>Contact Number : " + TextBox3.Text + "<br/><br/>Query : " + TextBox4.Text)

            mailMessage.IsBodyHtml = True
            Dim smtpClient As New SmtpClient("localhost")
            smtpClient.Credentials = System.Net.CredentialCache.DefaultCredentials
            smtpClient.UseDefaultCredentials = True
            smtpClient.Send(mailMessage)
            Response.Write(" Email Sent ")
        Catch ex As Exception
            Response.Write("Error : " + ex.Message)
        End Try

输出是这样的。

X-Sender: "Someone" <someone@abc.com>
X-Receiver: Someone@abc.com
MIME-Version: 1.0
From: "Someone" <Someone@abc.com>
To: Someone@abc.com
Date: 19 May 2015 19:35:49 +0530
Subject: Pink City Queries
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: quoted-printable`

<br>The following query was generated at 19-05-2015 19:35:49<br/>=
<br/>Name : Someone<br/><br/>Email : Someone@abc.com<br/><br/>Con=
tact Number : 0000000000<br/><br/>Query : Hello World!

【问题讨论】:

  • VB.NET 使用&amp; 进行字符串连接。如果您使用+,您可以进行魔术计算。如果您不使用Option Strict,那就更是如此。您还在正文的开头使用&lt;br&gt;。尝试始终使用&lt;br/&gt;
  • 一般你使用string.TrimEnd从字符串末尾删除不需要的字符,例如:str = str.TrimEnd("="c)

标签: html asp.net vb.net


【解决方案1】:

输出完全正确。没有必要摆脱任何东西。

电子邮件封装在quoted printable 中,= 表示换行符是软换行符

来自RFC 2045 spec

(软换行符)Quoted-Printable 编码 要求编码行不超过 76 长字符。如果要编码更长的行 对于 Quoted-Printable 编码,必须使用“软”换行符。等号作为 a 的最后一个字符 编码行表示这样一个不重要的(“软”) 编码文本中的换行符。

因此,如果该行的“原始”形式是单个未编码的行,
说:

Now's the time for all folk to come to the aid of their country.

这可以在 Quoted-Printable 编码中表示为:

Now's the time =
for all folk to come=
 to the aid of their country.

您可以通过电子邮件客户端或在线here 验证这一点。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-10-23
    • 1970-01-01
    • 2010-12-24
    • 2014-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-16
    相关资源
    最近更新 更多