Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Plain text and html not getting along in net.mail.message

Reply
Thread Tools

Plain text and html not getting along in net.mail.message

 
 
Rey
Guest
Posts: n/a
 
      11-13-2006
Howdy all.

Am using visual web developer 2005 (vb), xp pro sp2.

In testing of the system.net.mail to send email from an aspx page where
I'm pulling the email contents from a textbox, find that if I mix plain
text with html formatted text and set the isBodyHTML = true that I get
a continuous line of plain text without carriage returns and proper
HTML. I've a checkbox that if checked sets the IsBodyHTML=true.

email result:
nothing came through last time becuase txtbody was not assigned to
mailmessage body Testing change that allows html if checkbox checked
for it. Keep the carriage return? So them will this format correctly?
If not, will I need to use bodyencoding ut8? Or what? Then also send as
body is html to see difference? Maybe add a checkbox to use html...
"Element 'Import' is missing the '>' character from its start tag"
Done! <-- Done was centered and bolded in the email test.


**************************************
But if I send it as isBodyHTTML=false then I get carriage returns and
html tages displayed:

email result:
will it fail

Testing change to code that body is NOT HTML.
So them will this format correctly?

If not, will I need to use bodyencoding ut8?

Or what?

Then also send as body is html to see difference?

Maybe add a checkbox to use html...


"Element 'Import' is missing the '>' character from its start tag"

<p align=center>
<em><strong>Done!</strong></em>
</p>

***************************************
What I'd like is to understand whether I can mix the two - plain text
w/carriage returns & HTML - or whether I can have either one or the
other and not both without using alternativeview which I haven't yet
used but don't think its useful as I'm pulling the text from a textbox.

Appreciate any suggestion/comments.

Thank you,
Rey

*********************************************
Below is code being used.
Dim MyMail As MailMessage = New MailMessage()
Dim SMTPMail As SmtpClient = New SmtpClient("abc.beammeup.com")
Dim x As Int16

' new system.net.mail format
MyMail.From = New MailAddress("(E-Mail Removed)")

' intent is to separate to addresses on ;
' count them and loop to add
Dim arAddresses() As String = Split(txtSendTo, ";")
Dim intArrSize As Int16 = arAddresses.Length

Try

If arAddresses.Length > 1 Then
For x = 0 To arAddresses.Length - 1
MyMail.To.Add(arAddresses(x))
Next
Else
MyMail.To.Add(txtSendTo)

End If

MyMail.Subject = txtSubject.Text

' depending on whether cboHTML checkbox is checked
If cboHTML.Checked = True Then
' use html...
MyMail.IsBodyHtml = True
Else
MyMail.IsBodyHtml = False
End If

MyMail.BodyEncoding = Encoding.UTF8

' protect from scripts
'MyMail.Body = HttpUtility.HtmlEncode(txtBody.Text)

MyMail.Body = txtBody.Text

SMTPMail.Send(MyMail)

Catch httpexc As HttpRequestValidationException
txtErr.Text = "Problem encountered while attempting to send
email." & ControlChars.CrLf & _
"Please notify IT Dept with reason listed below." &
ControlChars.CrLf & _
"Reason: " & httpexc.Message

txtErr.Visible = True

Catch exc As Exception
txtErr.Text = "Problem encountered while attempting to send
email." & ControlChars.CrLf & _
"Please notify IT Dept with reason listed below." &
ControlChars.CrLf & _
"Reason: " & exc.Message

txtErr.Visible = True
End Try

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Thunderbird wraps plain text replies but not Opera Mail HTML replies janet Computer Support 11 12-17-2007 01:00 AM
ASP.NET 2.0 TreeView - node text as plain text (not hyperlink) Elton Pruitt ASP .Net 2 06-12-2006 12:41 PM
when I add HTML to innerHTML, FireFox renders it as HTML, but IE shows it as plain text Jake Barnes Javascript 9 02-21-2006 10:37 AM
Plain Text & Rich Text Formats Not Behaving: Thoughts On ? Robert11 Computer Support 9 11-28-2005 10:29 PM
HTML required for selecting text along with checkbox? (WebForms/mshtml designer question) Joergen Bech ASP .Net 0 07-27-2005 08:11 AM



Advertisments