我们在经典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。
答案 0 :(得分:6)
电子邮件中的感叹号通常是由于行太长造成的。将您在ASP中创建的电子邮件正文转储到文件中并进行检查。尝试使用换行符在明智的地方分割线条。我假设这是一条HTML消息 - 在适当的HTML标记之后放置换行符。
答案 1 :(得分:5)
我的代码只看到差异
.HTMLBody= psBody
.HTMLBodyPart.ContentTransferEncoding = "quoted-printable"
所以HTMLBodyPart....
取代BodyPart.....
不知道这是否有所作为,但你可以尝试一下。
答案 2 :(得分:0)
如果我没错,“引用可打印”的解决方案可以正常工作,但它会产生二进制附件的问题。所以我编写了一个小的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>")
%>
答案 3 :(得分: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"
它似乎完美无缺!
答案 4 :(得分: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>"