【问题标题】:open the mail on outlook using mailto encode problem使用 mailto 编码问题在 Outlook 上打开邮件
【发布时间】:2020-11-19 12:15:55
【问题描述】:

嗨,在我的网页中,我生成信息并使用 mailto 在 Outlook 上打开邮件,以便用户修改电子邮件。它工作得很好。但是,当正文或主题有引起问题的撇号时,我使用 Server.UrlEncode 对字符串进行编码。现在,空格显示“+”,换行显示“\n”。如果我不使用 Server.UrlEncode,则不会调用该函数。

在vb.net中有我调用javascript函数的代码

Dim strSubject As String = Server.UrlEncode(strName)
Dim strBody As String = Server.UrlEncode("it's your order list:" & "\r\n" & strList)
Dim script As String = "MailtoOrder(''," & "'" & strSubject & "', '" & strBody & "')"
If Not Page.ClientScript.IsStartupScriptRegistered(Me.GetType(), "mail") Then
                Page.ClientScript.RegisterStartupScript(Me.GetType(), "mail", script, True)
End If

有我的javascript:

function MailtoOrder( to, subject, body) {
   var email='';
   if (to != undefined) {
    email=to;
   }
    email = email + '&subject=' + encodeURIComponent(subject) + '&body=' + encodeURIComponent(body);  

    window.location.href = "mailto:" +   email;
}

【问题讨论】:

    标签: javascript asp.net vb.net


    【解决方案1】:

    我使用了 Server.UrlEncode。我只是将撇号替换为 strSubject 和 strBody 字符串中的转义字符。它有效。

    【讨论】:

      猜你喜欢
      • 2023-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-17
      • 2020-08-06
      • 2021-12-07
      • 1970-01-01
      • 2020-04-22
      相关资源
      最近更新 更多