3

我们在经典 ASP 中使用 CDO 对象在电子邮件正文中获得随机感叹号 (!) 标记。

我们没有在前景中看到这个感叹号。问题仅发生在 Lotus Notes 客户端。我们使用 IIS SMTP 服务器来发送电子邮件。

编辑

Set myMail= Server.CreateObject("CDO.Message")
myMail.Subject="Business and Company News on your Mobile Device"
myMail.From="no-reply@test.com"
myMail.To="some@email.com"
htmlbody = htmlbody (coming runtime)
myMail.BodyPart.ContentTransferEncoding = "quoted-printable"
myMail.HTMLBody = htmlbody
myMail.Send

我认为客户端没有使用 SMTP。但他们肯定在使用 LotusNotes。

4

5 回答 5

6

电子邮件中的感叹号通常是由于行太长造成的。将您在 ASP 中创建的电子邮件正文转储到一个文件并检查它。尝试使用换行符在合理的位置拆分行。我假设这是一条 HTML 消息 - 在适当的 HTML 标记之后放置换行符。

于 2010-02-01T16:02:26.920 回答
5

我在代码中看到的唯一区别是

 .HTMLBody= psBody
 .HTMLBodyPart.ContentTransferEncoding = "quoted-printable"

所以HTMLBodyPart....代替BodyPart.....

不知道这是否有区别,但你可以试试。

于 2010-02-01T16:44:52.630 回答
0

我发现的最佳解决方案是使用以下代码:

ObjMail.HtmlBody="text of your message"
'*** NOTE: the following instruction has to be placed HERE, just after the HtmlBody
ObjMail.HtmlBodyPart.ContentTransferEncoding = "quoted-printable"

它似乎完美无缺!

于 2014-03-20T16:33:30.057 回答
0

如果我没记错的话,“quoted-printable”解决方案有效,但它会产生二进制附件的问题。所以我写了一个小的 VbScript 函数来修复长字符串并使 htmlbody 与所有客户端兼容。这里是:

<%
'
' **** fix CDOSYS exclamation mark problem - TFI 10/22/2013 - v1.1
'
' This function breaks a string into 76 chars (or less) lines, thus avoiding
' the "exclamation mark" problem when sending e-mails through CDOSYS component
' v.1.1 - fixed a bug that clipped the message at its end

function fixstring(string1)
    Dim string2,pstart,pos0,pos1,part
    string2=""
    pstart=1
    do
        part=mid(string1,pstart,76)
        pos0=instr(part,vbcrlf)
        if pos0=0 then
            pos1=instrrev(part," ")
            if pos1=0 then
                string2=string2&part&vbcrlf
                pstart=pstart+76
            else
                string2=string2&left(part,pos1)&vbcrlf
                pstart=pstart+pos1
            end if  
        else
            string2=string2&left(part,pos0)&vbcrlf
            pstart=pstart+pos0
        end if  
    loop while pstart<len(string1)
    fixstring=string2
end function

string1="Lorem ipsum dolor sit"&vbcrlf&"amet, consectetur adipiscing elit. Sed in dignissim risus. Vestibulum ac justo sed massa posuere pellentesque non et odio. Suspendisse scelerisque sed ante in ullamcorper. Sed vel diam sed ligula commodo aliquet. Fusce aliquam eleifend arcu, vitae euismod purus pellentesque ac. In adipiscing, eros a semper semper, magna ligula volutpat dui, a vulputate nisl tellus a nisi. Donec et fringilla tellus. Praesent nibh neque, hendrerit ut fringilla eget, condimentum nec ligula. Mauris porta et velit et faucibus. Morbi aliquam risus urna, eu ultricies purus venenatis eget. Donec elementum ante dictum, euismod augue at, euismod lorem. Praesent sit amet tempus est. Nam et neque mollis, pretium ante sed, aliquet enim. abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrs Integer vestibulum lacus euismod lectus placerat, ut commodo metus tempor. Vivamus sagittis mauris id fringilla mattis. Nam convallis accumsan nulla nec eleifend. Suspendisse lobortis iaculis magna vel convallis. Ut id metus posuere, ullamcorper sapien at, sodales massa. Aenean commodo quis dolor vitae convallis. Duis sed metus non nisl commodo porttitor a sed augue. Vestibulum non risus bibendum, aliquam nulla vel, imperdiet sem. Suspendisse mattis eu lorem ac accumsan. Donec eget pulvinar libero. Nam cursus gravida gravida. Proin interdum elementum euismod. Nunc nec viverra ipsum. Nunc ultrices purus nisi, sed scelerisque elit suscipit ut. "
response.write "<b>string1:</b><br>"&string1&"<BR><br>"
response.write "<b>string2:</b><br>"&replace(fixstring(string1),vbcrlf,"<br>")
%>
于 2013-10-22T09:52:19.370 回答
0

当每行超过 750 个字符时会发生这种情况。尝试使用 vbNewLine 或 Chr(10) 来分割 html 中的行。

例子:

Set rs = conn.execute(txtsql)

html = ""
html = html & "<h1>Hi " & rs("Engineer_Name") & "</h1>" & vbNewLine
html = html & "<div class=''><table class='maintable'>" & vbNewLine
html = html &   "<thead>"
html = html &       "<tr>"
html = html &           "<th>ID</th>"
html = html &           "<th>Title</th>"
html = html &       "</tr>"
html = html &   "</thead>" & vbNewLine
html = html &   "<tbody>" & vbNewLine

Do Until rs.EOF
    html = html &       "<tr>"
    html = html &           "<td>" & rs("ID_Calendar") & "</td>"
    html = html &           "<td>" & rs("Title") & "</td>"
    html = html &       "</tr>" & vbNewLine
    rs.movenext
Loop

html = html &   "</tbody>" & vbNewLine
html = html & "</table></div>"
于 2018-04-03T13:13:21.220 回答