Случайный восклицательный знак в теле письма с использованием CDO - PullRequest
3 голосов
/ 01 февраля 2010

Мы получаем случайный восклицательный знак (!) В теле письма, используя объект CDO в Classic ASP.

Мы не получаем этот восклицательный знак с прогнозом. Проблема возникает только с клиентом Lotus Notes. Мы используем SMTP-сервер IIS для отправки электронной почты.

Редактировать

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.

Ответы [ 5 ]

6 голосов
/ 01 февраля 2010

Восклицательные знаки в электронных письмах обычно вызваны слишком длинными строками. Скопируйте тело письма, которое вы создаете в ASP, в файл и изучите его. Попробуйте разбить строки в разумных местах с помощью новых строк. Я предполагаю, что это сообщение HTML - ставьте новые строки после соответствующих тегов HTML.

5 голосов
/ 01 февраля 2010

Единственная разница, которую я вижу с моим кодом,

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

То есть HTMLBodyPart.... вместо BodyPart.....

Не знаю, имеет ли это значение, но вы можете попробовать.

0 голосов
/ 03 апреля 2018

Это происходит, когда в строке более 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>"
0 голосов
/ 20 марта 2014

Лучшее решение, которое я нашел, это использовать этот код:

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

Кажется, работает безупречно!

0 голосов
/ 22 октября 2013

Если я не ошибаюсь, решение "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>")
%>
...