468,253 Members | 1,286 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,253 developers. It's quick & easy.

trimmed string after replace function

Hi,

I have a mystery to solve. It is a mystery because it happens randomly.
In the ASP page that is in question, I build a large string (no more
than 10K) which is basically an email template in HTML format. Then I
replace the parts with the values, which are also strings with the size
of 1-2 KB.

For example:

order_summary = generateOrderSummary() 'This HTML string is no more
than 4-5 KB

send_email (order_summary, to_sales_department) 'This email goes to
sales dept, they receive it OK.

email_body = readFromFile("HTML_email_template.html") ' This is 10KB

email_body = replace (email_body, "<!-- NAME -->", billing_name)

email_body = replace (email_body, "<!-- ORDER SUMMARY -->",
order_summary)

email_body = replace (email_body, "<!-- OTHER -->", other_stuff)

send_email (email_body, to_customer) ' They sometimes receive trimmed
order summary.

Here is the mystery: sometimes recipients complain that their order
confirmation is wrong because it seems order_summary part is trimmed.
They fw me the email and yes it was trimmed, however the rest of the
email is OK: just the order_summary in the middle of the email was
messed up. Since order_summary shows OK on the first email, and not on
the second email I concluded that there must be something with the
replace function. It doesn't happen a lot, there are only 2 known cases
out of couple thousands. It is not order-specific either, I place the
same order and order_summary shows OK.

Any suggestions on how to isolate the problem?
Have you encountered the same/similar problems with strings?

I use ASP 3.0 on IIS 6.0. Server is Windows 2003.

Thanks

Deniz

Jan 15 '07 #1
7 1708

"denoxis" <go****@deniznet.comwrote in message
news:11*********************@s34g2000cwa.googlegro ups.com...
Hi,

I have a mystery to solve. It is a mystery because it happens randomly.
In the ASP page that is in question, I build a large string (no more
than 10K) which is basically an email template in HTML format. Then I
replace the parts with the values, which are also strings with the size
of 1-2 KB.

For example:

order_summary = generateOrderSummary() 'This HTML string is no more
than 4-5 KB

send_email (order_summary, to_sales_department) 'This email goes to
sales dept, they receive it OK.

email_body = readFromFile("HTML_email_template.html") ' This is 10KB

email_body = replace (email_body, "<!-- NAME -->", billing_name)

email_body = replace (email_body, "<!-- ORDER SUMMARY -->",
order_summary)

email_body = replace (email_body, "<!-- OTHER -->", other_stuff)

send_email (email_body, to_customer) ' They sometimes receive trimmed
order summary.

Here is the mystery: sometimes recipients complain that their order
confirmation is wrong because it seems order_summary part is trimmed.
They fw me the email and yes it was trimmed, however the rest of the
email is OK: just the order_summary in the middle of the email was
messed up. Since order_summary shows OK on the first email, and not on
the second email I concluded that there must be something with the
replace function. It doesn't happen a lot, there are only 2 known cases
out of couple thousands. It is not order-specific either, I place the
same order and order_summary shows OK.

Any suggestions on how to isolate the problem?
Have you encountered the same/similar problems with strings?
It has been known that if the html body part of the email is not encoded
using quoted-printable encoding that white space gets inserted into html tag
names. When that happens the html output gets messed up.

I use ASP 3.0 on IIS 6.0. Server is Windows 2003.

Thanks

Deniz

Jan 15 '07 #2
denoxis wrote:
Any suggestions on how to isolate the problem?
Have you encountered the same/similar problems with strings?
What happens when you change this...
email_body = replace (email_body, "<!-- ORDER SUMMARY -->",
order_summary)
....to this?

email_body = replace(email_body, "<!-- ORDER SUMMARY -->",
Server.HTMLEncode(order_summary))

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Jan 16 '07 #3
If I do that I see the HTML source in the email! Doesn't HTMLEncode
change "<" to &lt; and ">" to &gt; etc? I don't want that, my email
*is* in HTML, I want to keep the tags so my email would be formatted
accordingly.

Deniz

Dave Anderson wrote:
denoxis wrote:
Any suggestions on how to isolate the problem?
Have you encountered the same/similar problems with strings?

What happens when you change this...
email_body = replace (email_body, "<!-- ORDER SUMMARY -->",
order_summary)

...to this?

email_body = replace(email_body, "<!-- ORDER SUMMARY -->",
Server.HTMLEncode(order_summary))

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Jan 16 '07 #4
denoxis wrote:
> email_body = replace(email_body, "<!-- ORDER SUMMARY -->",
Server.HTMLEncode(order_summary))

If I do that I see the HTML source in the email! Doesn't HTMLEncode
change "<" to &lt; and ">" to &gt; etc? I don't want that, my email
*is* in HTML, I want to keep the tags so my email would be formatted
accordingly.
Right. But you did not try, so you did not find out if your content is
actually present.

I made the suggestion so you could determine whether you were simply guilty
of writing sloppy HTML in the affected section. NOT VISIBLE does not equal
NOT THERE when it comes to HTML, after all. I suppose you can still [view
source] on the offending messages if you want to know for sure.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Jan 17 '07 #5

Dave Anderson wrote:
denoxis wrote:
email_body = replace(email_body, "<!-- ORDER SUMMARY -->",
Server.HTMLEncode(order_summary))
If I do that I see the HTML source in the email! Doesn't HTMLEncode
change "<" to &lt; and ">" to &gt; etc? I don't want that, my email
*is* in HTML, I want to keep the tags so my email would be formatted
accordingly.

Right. But you did not try, so you did not find out if your content is
actually present.
I appreciate the suggestion, I did try it before I post my answer and
that's what I saw: piece of HTML source code in the middle of HTML
email, which would show correctly if it was real HTML. I thought you
suggested that those codes would translate back to normal HTML in the
email.
I made the suggestion so you could determine whether you were simply guilty
of writing sloppy HTML in the affected section. NOT VISIBLE does not equal
NOT THERE when it comes to HTML, after all. I suppose you can still [view
source] on the offending messages if you want to know for sure.
Sloppy HTML is less likely since it is generated in a loop for each
product. Something like:
....
"<tr><td>" & product_name & "</td><td>" & price & "</td><td>" & qty &
"</td></tr>"
....
I did make sure product names don't contain weird characters (such as <
and >) By looking at the source code of the email that is in question,
I see part of the HTML is missing with no trace

I did however one thing: adding linebreaks in the HTML-generating loop
(otherwise there could be a very long line depending on the order size,
which is actually reason of some of the bounce-backs) So maybe it is
line-length related issue. We will see if adding '& vbcrlf' to the end
of the code above helps.

Thanks for the answers

Deniz
>
--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Jan 18 '07 #6

"denoxis" <go****@deniznet.comwrote in message
news:11**********************@v45g2000cwv.googlegr oups.com...
>
Dave Anderson wrote:
denoxis wrote:
> email_body = replace(email_body, "<!-- ORDER SUMMARY -->",
> Server.HTMLEncode(order_summary))
>
If I do that I see the HTML source in the email! Doesn't HTMLEncode
change "<" to &lt; and ">" to &gt; etc? I don't want that, my email
*is* in HTML, I want to keep the tags so my email would be formatted
accordingly.
Right. But you did not try, so you did not find out if your content is
actually present.

I appreciate the suggestion, I did try it before I post my answer and
that's what I saw: piece of HTML source code in the middle of HTML
email, which would show correctly if it was real HTML. I thought you
suggested that those codes would translate back to normal HTML in the
email.
I made the suggestion so you could determine whether you were simply
guilty
of writing sloppy HTML in the affected section. NOT VISIBLE does not
equal
NOT THERE when it comes to HTML, after all. I suppose you can still
[view
source] on the offending messages if you want to know for sure.

Sloppy HTML is less likely since it is generated in a loop for each
product. Something like:
...
"<tr><td>" & product_name & "</td><td>" & price & "</td><td>" & qty &
"</td></tr>"
...
I did make sure product names don't contain weird characters (such as <
and >) By looking at the source code of the email that is in question,
I see part of the HTML is missing with no trace

I did however one thing: adding linebreaks in the HTML-generating loop
(otherwise there could be a very long line depending on the order size,
which is actually reason of some of the bounce-backs) So maybe it is
line-length related issue. We will see if adding '& vbcrlf' to the end
of the code above helps.
Have you yet confirmed whether the HTML body part is being encoded as
quoted-printable. I said this already but you didn't respond. If you
haven't you could well save yourself a lot of time but just checking. It is
the most likely cause of your problem.


Jan 19 '07 #7
Anthony,

I am sorry, I didn't read the answer carefully, I thought you were
suggesting the same thing. Actually you may be pointing out to the core
of the problem. I thought these kind of encodings were done
automatically by the email sender component, however I just checked the
reference for it and it says I have to set ContentTransferEncoding
property to "quoted-printable" to have quoted-printable. So I will
definitely try that.

Thanks for the followup!!!

Deniz
Anthony Jones wrote:
>
Have you yet confirmed whether the HTML body part is being encoded as
quoted-printable. I said this already but you didn't respond. If you
haven't you could well save yourself a lot of time but just checking. It is
the most likely cause of your problem.
Jan 23 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by higabe | last post: by
13 posts views Thread by dimitris67 | last post: by
5 posts views Thread by djc | last post: by
16 posts views Thread by ^MisterJingo^ | last post: by
10 posts views Thread by TC | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.