ASP CDO sending MS Word copied text

N

nathan _

I have a page which sends out email, the content of which is often
pasted from a MS Word document. When this message is received in Outlook
the character coding is out and doesn't display properly:

Following is an example of what does not display correctly:

*********************************************************

Const cdoFlushBuffersOnWrite =
"http://schemas.microsoft.com/cdo/configuration/flushbuffersonwrite"
Const cdoSMTPServerPickupDirectory =
"http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirector
y"

Dim oMsg : Set oMsg = CreateObject("CDO.Message")

Set oMsg.Configuration = CreateObject("CDO.Configuration")

strSmtpServer = "server ip here"
strUser = "username here"
strPassword = "password here"


With oMsg.Configuration.Fields
..Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
..Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
strSmtpServer
..Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")
= 1
..Item("http://schemas.microsoft.com/cdo/configuration/sendusername") =
strUser
..Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") =
strPassword
..Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") =
25
..Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") =
False
..Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontime
out") = 60


'.Item(cdoFlushBuffersOnWrite) = True
'.Item(cdoSMTPServerPickupDirectory) = "c:\temp\pickup" '*** change this
..Update
End With

oMsg.BodyPart.charset = "UTF-8"

oMsg.From = "address goes here"
oMsg.To = "address goes here"
oMsg.Subject = "Testing"
oMsg.HTMLBody = "<TABLE style=""BORDER-COLLAPSE: collapse;
mso-yfti-tbllook: 480; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt""
class=MsoTableGrid border=0 cellSpacing=0 cellPadding=0><TBODY><TR
style=""mso-yfti-irow: 0; mso-yfti-firstrow: yes"">" & _
"<TD style=""BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0;
PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt;
WIDTH: 166.55pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0;
BORDER-RIGHT: #f0f0f0; PADDING-TOP: 0cm"" vAlign=top width=222>" & _
"<P style=""TEXT-ALIGN: left; MARGIN: 0cm 0cm 12pt; tab-stops: 54.0pt
right 467.7pt"" class=MsoNormal align=left><SPAN style=""FONT-SIZE:
10pt; mso-bidi-font-family: Arial; mso-bidi-font-weight: bold""><FONT
face=Arial>“<B>Admission
Document</B>”<o:p></o:p></FONT></SPAN></P></TD>" & _
"<TD style=""BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0;
PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt;
WIDTH: 243.9pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT:
#f0f0f0; PADDING-TOP: 0cm"" vAlign=top width=325>" & _
"<P style=""TEXT-ALIGN: left; MARGIN: 0cm 0cm 12pt; tab-stops: 54.0pt
right 467.7pt"" class=MsoNormal align=left><SPAN style=""FONT-SIZE:
10pt; mso-bidi-font-family: Arial""><FONT face=Arial>the Company’s AIM
admission document dated 15 September
2006;<o:p></o:p></FONT></SPAN></P></TD></TR>" & _
"<TR style=""mso-yfti-irow: 3"">" & _
"<TD style=""BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0;
PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt;
WIDTH: 166.55pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0;
BORDER-RIGHT: #f0f0f0; PADDING-TOP: 0cm"" vAlign=top width=222>" & _
"<P style=""MARGIN: 0cm 0cm 12pt; tab-stops: 54.0pt right 467.7pt""
class=MsoNormal><SPAN style=""FONT-SIZE: 10pt; mso-bidi-font-family:
Arial""><FONT face=Arial>‘‘<B style=""mso-bidi-font-weight:
normal"">certificated</B>’’ or ‘‘<B style=""mso-bidi-font-weight:
normal"">in certificated form</B>”<SPAN style=""mso-bidi-font-weight:
bold""><o:p></o:p></SPAN></FONT></SPAN></P></TD>" & _
"<TD style=""BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0;
PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt;
WIDTH: 243.9pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT:
#f0f0f0; PADDING-TOP: 0cm"" vAlign=top width=325>" & _
"<P style=""MARGIN: 0cm 0cm 12pt; tab-stops: 54.0pt right 467.7pt""
class=MsoNormal><SPAN style=""FONT-SIZE: 10pt; mso-bidi-font-family:
Arial""><FONT face=Arial>not in uncertificated form;
<o:p></o:p></FONT></SPAN></P></TD></TR></tbody></table>"

oMsg.Send

*********************************************************

If i run the above from a VBS file the email displays fine and if i
export that message out to an eml file from the vbs it displays fine
too.

header for eml is:

---------------------------------------------------------

X-Receiver: (e-mail address removed)
X-Sender: (e-mail address removed)
thread-index: AcpMy9QPm8736OfKSX6zKvmrtEmxgw==
Thread-Topic: Testing
From: <[email protected]>
To: <[email protected]>
Subject: Testing
Date: Wed, 14 Oct 2009 13:42:45 +0100
Message-ID: <9A2C7BC5F87341878A421C463FE60A6B@nathanlaptop>
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_0000_01CA4CD4.35D5C420"
X-Mailer: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6002.18005

This is a multi-part message in MIME format.

------=_NextPart_000_0000_01CA4CD4.35D5C420
Content-Type: text/plain;
charset="UTF-8"
Content-Transfer-Encoding: base64

** CONTENT REMOVED **

------=_NextPart_000_0000_01CA4CD4.35D5C420
Content-Type: text/html;
charset="UTF-8"
Content-Transfer-Encoding: 8bit
 
A

Adrienne Boswell

Gazing into my crystal ball I observed nathan _
I have a page which sends out email, the content of which is often
pasted from a MS Word document. When this message is received in Outlook
the character coding is out and doesn't display properly:

Following is an example of what does not display correctly:

*********************************************************

Const cdoFlushBuffersOnWrite =
"http://schemas.microsoft.com/cdo/configuration/flushbuffersonwrite"
Const cdoSMTPServerPickupDirectory =
"http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirect or
y"

Dim oMsg : Set oMsg = CreateObject("CDO.Message")

Set oMsg.Configuration = CreateObject("CDO.Configuration")

strSmtpServer = "server ip here"
strUser = "username here"
strPassword = "password here"


With oMsg.Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
strSmtpServer
.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")
= 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") =
strUser
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") =
strPassword
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") =
25
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") =
False
.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontime
out") = 60


'.Item(cdoFlushBuffersOnWrite) = True
'.Item(cdoSMTPServerPickupDirectory) = "c:\temp\pickup" '*** change this
.Update
End With

oMsg.BodyPart.charset = "UTF-8"

oMsg.From = "address goes here"
oMsg.To = "address goes here"
oMsg.Subject = "Testing"
oMsg.HTMLBody = "<TABLE style=""BORDER-COLLAPSE: collapse;
mso-yfti-tbllook: 480; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt""
class=MsoTableGrid border=0 cellSpacing=0 cellPadding=0><TBODY><TR
style=""mso-yfti-irow: 0; mso-yfti-firstrow: yes"">" & _
"<TD style=""BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0;
PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt;
WIDTH: 166.55pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0;
BORDER-RIGHT: #f0f0f0; PADDING-TOP: 0cm"" vAlign=top width=222>" & _
"<P style=""TEXT-ALIGN: left; MARGIN: 0cm 0cm 12pt; tab-stops: 54.0pt
right 467.7pt"" class=MsoNormal align=left><SPAN style=""FONT-SIZE:
10pt; mso-bidi-font-family: Arial; mso-bidi-font-weight: bold""><FONT
face=Arial>“<B>Admission
Document</B>”<o:p></o:p></FONT></SPAN></P></TD>" & _
"<TD style=""BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0;
PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt;
WIDTH: 243.9pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER- RIGHT:
#f0f0f0; PADDING-TOP: 0cm"" vAlign=top width=325>" & _
"<P style=""TEXT-ALIGN: left; MARGIN: 0cm 0cm 12pt; tab-stops: 54.0pt
right 467.7pt"" class=MsoNormal align=left><SPAN style=""FONT-SIZE:
10pt; mso-bidi-font-family: Arial""><FONT face=Arial>the Company’s AIM
admission document dated 15 September
2006;<o:p></o:p></FONT></SPAN></P></TD></TR>" & _
"<TR style=""mso-yfti-irow: 3"">" & _
"<TD style=""BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0;
PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt;
WIDTH: 166.55pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0;
BORDER-RIGHT: #f0f0f0; PADDING-TOP: 0cm"" vAlign=top width=222>" & _
"<P style=""MARGIN: 0cm 0cm 12pt; tab-stops: 54.0pt right 467.7pt""
class=MsoNormal><SPAN style=""FONT-SIZE: 10pt; mso-bidi-font-family:
Arial""><FONT face=Arial>‘‘<B style=""mso-bidi-font-weight:
normal"">certificated</B>’’ or ‘‘<B style=""mso-bidi-font-weight:
normal"">in certificated form</B>”<SPAN style=""mso-bidi-font-weight:
bold""><o:p></o:p></SPAN></FONT></SPAN></P></TD>" & _
"<TD style=""BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0;
PADDING-BOTTOM: 0cm; BACKGROUND-COLOR: transparent; PADDING-LEFT: 5.4pt;
WIDTH: 243.9pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: #f0f0f0; BORDER- RIGHT:
#f0f0f0; PADDING-TOP: 0cm"" vAlign=top width=325>" & _
"<P style=""MARGIN: 0cm 0cm 12pt; tab-stops: 54.0pt right 467.7pt""
class=MsoNormal><SPAN style=""FONT-SIZE: 10pt; mso-bidi-font-family:
Arial""><FONT face=Arial>not in uncertificated form;
<o:p></o:p></FONT></SPAN></P></TD></TR></tbody></table>"

oMsg.Send

*********************************************************

If i run the above from a VBS file the email displays fine and if i
export that message out to an eml file from the vbs it displays fine
too.

header for eml is:

---------------------------------------------------------

X-Receiver: (e-mail address removed)
X-Sender: (e-mail address removed)
thread-index: AcpMy9QPm8736OfKSX6zKvmrtEmxgw==
Thread-Topic: Testing
From: <[email protected]>
To: <[email protected]>
Subject: Testing
Date: Wed, 14 Oct 2009 13:42:45 +0100
Message-ID: <9A2C7BC5F87341878A421C463FE60A6B@nathanlaptop>
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_0000_01CA4CD4.35D5C420"
X-Mailer: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6002.18005

This is a multi-part message in MIME format.

------=_NextPart_000_0000_01CA4CD4.35D5C420
Content-Type: text/plain;
charset="UTF-8"
Content-Transfer-Encoding: base64

** CONTENT REMOVED **

------=_NextPart_000_0000_01CA4CD4.35D5C420
Content-Type: text/html;
charset="UTF-8"
Content-Transfer-Encoding: 8bit

Personally, I would clean up that mess of HTMLBody. Just use clean
markup and you should be okay.

You can go from 40 lines to 2:

oMsg.HTMLBody = "<h1>Admission Document</h1>" & _
"<p>The Company’s AIM admission document dated 15 September
2006 <strong>certificated</strong> or <strong>in certificated form
</strong> not in uncertificated form.</p>"
 
N

nathan _

I will explain again better; I have an emailing system which people use
to copy text from Word and then paste into this system to send out
messages. I am fully aware I could change the html but that is not my
problem. The html was given as an example so this issue can be
replicated, this is a dynamic field in the real application.

I am pretty sure it's down to a character set issue which can be
resolved, I've tried a few different changes without luck and was hoping
someone would have come across something similar before.
 
A

Adrienne Boswell

Gazing into my crystal ball I observed nathan _
I will explain again better; I have an emailing system which people use
to copy text from Word and then paste into this system to send out
messages. I am fully aware I could change the html but that is not my
problem.

You see, with markup as bad as that, there is no way to know WHAT an email
client is going to do with it.
The html was given as an example so this issue can be
replicated, this is a dynamic field in the real application.

So you really are using that drivel? FYI - you're missing a TR element
towards the top.
I am pretty sure it's down to a character set issue which can be
resolved, I've tried a few different changes without luck and was hoping
someone would have come across something similar before.

Here's what I think is happening:
1. You spit out bad markup
2. The client pastes from a Word document
3. Outlook sees your bad markup, the pasted bad markup and does not know
what to do with it. Trouble cascades.

Can you show us some clean markup with something pasted from Word
(something small, please).
 
N

nathan _

To explain again; this is not an issue about markup. If i create an
email with this html outside of my ASP web application it displays fine.
This is about character sets. Please understand I am not here for html
advice, I am fully aware what MS Word produces is inefficent and ugly
html. I am after advice regarding character encoding.

thanks.
 
A

Adrienne Boswell

Gazing into my crystal ball I observed nathan _
To explain again; this is not an issue about markup. If i create an
email with this html outside of my ASP web application it displays fine.
This is about character sets. Please understand I am not here for html
advice, I am fully aware what MS Word produces is inefficent and ugly
html. I am after advice regarding character encoding.

thanks.

Does this help?
http://www.freesoft.org/CIE/RFC/1521/7.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top