Question about sending email via Visual Basic 2005 on a ASP.NET pa

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello everyone-

I am hoping a couple of you will have some ideas on this one...

I have a webform created in visual basic 2005.
Basically, the webform gather answers to the questions asked on the form and
included a couple free type multine textboxes.

When the user presses submit an message is created with the responses and
fired off to a MS Exchange mail enabled public folder.

This is an external webform btw, not used by internal users.

Problem:
After some fighting, I have the mail message formatted pretty as it was
requested and I have it coming in HTML form: MailMessage.IsBodyHtml = True
For the most part.

My hang up is the couple free text multi line text boxes don't word wrap so
well (all the time).
When I view them, using MS Outlook 2007 those sections word wrap just fine
in the public folder post. However, are admins in the other sections, using
MS Outlook 2003, do not show the word wrap.

Outlook 2007 on my pc and Outlook 2003 on their pc are set to view messages
in HTML mode. As far as I can tell, other then being different versions -
are settings are similar.

Not sure if there is something I could do programmatically to get around
this issue or not?

Again, everything seems great - except those couple multiline text box
objects....

I tried playing around with the html <PRE> tags and that didn't even help.

I been digging through blogs and other posts for about 2 hours now - no luck.

Anyone have any ideas?
 
Hello everyone-

I am hoping a couple of you will have some ideas on this one...

I have a webform created in visual basic 2005.
Basically, the webform gather answers to the questions asked on the form and
included a couple free type multine textboxes.

When the user presses submit an message is created with the responses and
fired off to a MS Exchange mail enabled public folder.

This is an external webform btw, not used by internal users.

Problem:
After some fighting, I have the mail message formatted pretty as it was
requested and I have it coming in HTML form: MailMessage.IsBodyHtml = True
For the most part.

My hang up is the couple free text multi line text boxes don't word wrap so
well (all the time).
When I view them, using MS Outlook 2007 those sections word wrap just fine
in the public folder post. However, are admins in the other sections, using
MS Outlook 2003, do not show the word wrap.

Outlook 2007 on my pc and Outlook 2003 on their pc are set to view messages
in HTML mode. As far as I can tell, other then being different versions -
are settings are similar.

Not sure if there is something I could do programmatically to get around
this issue or not?

Again, everything seems great - except those couple multiline text box
objects....

I tried playing around with the html <PRE> tags and that didn't even help.

I been digging through blogs and other posts for about 2 hours now - no luck.

Anyone have any ideas?

I might embarrass myself with this on-the-fly Regex pattern, but here
it goes:

You could use regex to match the text in each line of the multiline
textbox, then add a <br /> tag to the end of each line.

This assumes an Imports System.Text.RegularExpressions:

' This is typed in the message so it may contain errors

Dim output as String = ""
For Each m as Match in Regex.Matches(me.TextBox1.Text, "(?=[^\r
\n]).*(?<![\r\n])", RegexOptions.Multiline))
output &= String.Format("{0}<br />", m.Value)
Next
' Then just use the "output" string in your email

Thanks,

Seth Rowe
 
rowe_newsgroups said:
Hello everyone-
You could use regex to match the text in each line of the multiline
textbox, then add a <br /> tag to the end of each line.

This assumes an Imports System.Text.RegularExpressions:

' This is typed in the message so it may contain errors

Dim output as String = ""
For Each m as Match in Regex.Matches(me.TextBox1.Text, "(?=[^\r
\n]).*(?<![\r\n])", RegexOptions.Multiline))
output &= String.Format("{0}<br />", m.Value)
Next
' Then just use the "output" string in your email

Perhaps I didn't fully understand the question, but I'm doing something
similar myself and what worked for me was to simply scan for vbcrlf in the
textbox text and then replace with both a duplicate vbcrlf and a <br> tag.
I'm still new to email creation, but this seems to permit the proper viewing
by both html enabled email software that seems to ignore the vbcrlf and by
plain-text only software the ignores the html tags.

It is similar in function to the above, but much easier to code. My code is
below

Msg = Replace(Msg, vbCrLf, vbCrLf & "<br>")

Jeff
 
Seth-

Thank you for the info!

I did a test and the regular expression road you pointed me down does work,
but I initally tried to steer clear of regular expressions due to the
difficulty in someone else just taking a look at it later and being able to
easily read it.

I choose another option, giving up perhaps the better way for readability.

I know regular expressions is probably the best way and I need get more
familar with them, but perhaps I will drive that road in another couple
months.

Thanks-

Tony Wissler

rowe_newsgroups said:
Hello everyone-

I am hoping a couple of you will have some ideas on this one...

I have a webform created in visual basic 2005.
Basically, the webform gather answers to the questions asked on the form and
included a couple free type multine textboxes.

When the user presses submit an message is created with the responses and
fired off to a MS Exchange mail enabled public folder.

This is an external webform btw, not used by internal users.

Problem:
After some fighting, I have the mail message formatted pretty as it was
requested and I have it coming in HTML form: MailMessage.IsBodyHtml = True
For the most part.

My hang up is the couple free text multi line text boxes don't word wrap so
well (all the time).
When I view them, using MS Outlook 2007 those sections word wrap just fine
in the public folder post. However, are admins in the other sections, using
MS Outlook 2003, do not show the word wrap.

Outlook 2007 on my pc and Outlook 2003 on their pc are set to view messages
in HTML mode. As far as I can tell, other then being different versions -
are settings are similar.

Not sure if there is something I could do programmatically to get around
this issue or not?

Again, everything seems great - except those couple multiline text box
objects....

I tried playing around with the html <PRE> tags and that didn't even help.

I been digging through blogs and other posts for about 2 hours now - no luck.

Anyone have any ideas?

I might embarrass myself with this on-the-fly Regex pattern, but here
it goes:

You could use regex to match the text in each line of the multiline
textbox, then add a <br /> tag to the end of each line.

This assumes an Imports System.Text.RegularExpressions:

' This is typed in the message so it may contain errors

Dim output as String = ""
For Each m as Match in Regex.Matches(me.TextBox1.Text, "(?=[^\r
\n]).*(?<![\r\n])", RegexOptions.Multiline))
output &= String.Format("{0}<br />", m.Value)
Next
' Then just use the "output" string in your email

Thanks,

Seth Rowe
 
Jeff-

Thanks for the info, I gave this a try and it worked great for what I wanted
to do.
The formatting looks good now in both MS Outlook 2007 and MS Outlook 2003.

Regular Expressions is probably the best way (as mentioned above), but I
went this route for ease of readability and I am not concerned about speed on
this particular web form as I don't see the traffic being that extreme.

Thanks-

Tony Wissler

Jeff said:
rowe_newsgroups said:
Hello everyone-
You could use regex to match the text in each line of the multiline
textbox, then add a <br /> tag to the end of each line.

This assumes an Imports System.Text.RegularExpressions:

' This is typed in the message so it may contain errors

Dim output as String = ""
For Each m as Match in Regex.Matches(me.TextBox1.Text, "(?=[^\r
\n]).*(?<![\r\n])", RegexOptions.Multiline))
output &= String.Format("{0}<br />", m.Value)
Next
' Then just use the "output" string in your email

Perhaps I didn't fully understand the question, but I'm doing something
similar myself and what worked for me was to simply scan for vbcrlf in the
textbox text and then replace with both a duplicate vbcrlf and a <br> tag.
I'm still new to email creation, but this seems to permit the proper viewing
by both html enabled email software that seems to ignore the vbcrlf and by
plain-text only software the ignores the html tags.

It is similar in function to the above, but much easier to code. My code is
below

Msg = Replace(Msg, vbCrLf, vbCrLf & "<br>")

Jeff
 
Tony Wissler said:
Jeff-

Thanks for the info, I gave this a try and it worked great for what I
wanted
to do.
The formatting looks good now in both MS Outlook 2007 and MS Outlook 2003.

Regular Expressions is probably the best way (as mentioned above), but I
went this route for ease of readability and I am not concerned about speed
on
this particular web form as I don't see the traffic being that extreme.

Thanks-

Tony Wissler


Umm, the first time that I successfully actually answered a question for
someone else rather than the other way around.

I must be learning something - it's a scary thought.

Jeff
 
Back
Top