Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP General (http://www.velocityreviews.com/forums/f65-asp-general.html)
-   -   ASP CDO sending MS Word copied text (http://www.velocityreviews.com/forums/t804956-asp-cdo-sending-ms-word-copied-text.html)

nathan _ 10-14-2009 02:01 PM

ASP CDO sending MS Word copied text
 
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: Dude@somewhere.com
X-Sender: Dude@somewhere.com
thread-index: AcpMy9QPm8736OfKSX6zKvmrtEmxgw==
Thread-Topic: Testing
From: <Dude@somewhere.com>
To: <Dude@somewhere.com>
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

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

Any suggestions / help would be greatly appreciated.

*** Sent via Developersdex http://www.developersdex.com ***

Adrienne Boswell 10-14-2009 03:05 PM

Re: ASP CDO sending MS Word copied text
 
Gazing into my crystal ball I observed nathan _
<nathancorridon@lineone.net> writing in news:eL4xNbNTKHA.3404
@TK2MSFTNGP04.phx.gbl:

> 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: Dude@somewhere.com
> X-Sender: Dude@somewhere.com
> thread-index: AcpMy9QPm8736OfKSX6zKvmrtEmxgw==
> Thread-Topic: Testing
> From: <Dude@somewhere.com>
> To: <Dude@somewhere.com>
> 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
>
> ---------------------------------------------------------
>
> Any suggestions / help would be greatly appreciated.
>
> *** Sent via Developersdex http://www.developersdex.com ***
>


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>"

--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share


nathan _ 10-15-2009 07:31 AM

Re: ASP CDO sending MS Word copied text
 
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.

*** Sent via Developersdex http://www.developersdex.com ***

Adrienne Boswell 10-15-2009 01:35 PM

Re: ASP CDO sending MS Word copied text
 
Gazing into my crystal ball I observed nathan _
<nathancorridon@lineone.net> writing in news:#YEZ6lWTKHA.5052
@TK2MSFTNGP05.phx.gbl:

> 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).


--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share


nathan _ 10-15-2009 03:38 PM

Re: ASP CDO sending MS Word copied text
 
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.

*** Sent via Developersdex http://www.developersdex.com ***

Adrienne Boswell 10-15-2009 07:04 PM

Re: ASP CDO sending MS Word copied text
 
Gazing into my crystal ball I observed nathan _
<nathancorridon@lineone.net> writing in news:Og#4F2aTKHA.4000
@TK2MSFTNGP05.phx.gbl:

> 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


--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share



All times are GMT. The time now is 04:59 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.