473,394 Members | 1,640 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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

Rey
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("IT********@hotdogs.com")

' 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

Nov 13 '06 #1
0 1853

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: LRW | last post by:
Because I've had recipients of our newsletter tell us they can't (or won't) receive HTML e-mail, I found out how to make an e-mail that sends both HTML and a plaintext version in a multipart...
11
by: Inkiniteo | last post by:
Hi guys. I have a script that sends the info by email, but i'd like to avoid the convertion to HTML by the email client or Gmail, because it ruins all the formatting i did (with tabs, mostly)....
10
by: J. Alan Rueckgauer | last post by:
Hello. I'm looking for a simple way to do the following: We have a database that serves-up content to a website. Some of those items are events, some are news articles. They're stored in the...
1
by: Karl B | last post by:
Hi all. Iv'e tryed out xp_smtp_sendmail, and I like what I can see so far. The thing I wonder about is if the xp supports sending both html AND plain text in the same mail. I'm on a sql2000 sp3 and...
8
by: LRW | last post by:
I'm not sure this message is totally appropriate for this group, so please, if anyone has a better group suggestion, let me know! My company sends out a monthly newsletter in HTML format to our...
4
by: Zephyr . via .NET 247 | last post by:
(Type your message here) -------------------------------- From: Zephyr . hey, i got trouble getting integers out of a plain text file. i dont want to use binary files, just plain text files...
10
by: Eric Lindsay | last post by:
This may be too far off topic, however I was looking at this page http://www.hixie.ch/advocacy/xhtml about XHTML problems by Ian Hickson. It is served as text/plain, according to Firefox...
6
by: monomaniac21 | last post by:
hi all how can u send a plain text version of an email with the html so that the users mail client can access this plain text version? kind regards marc
27
matheussousuke
by: matheussousuke | last post by:
I'm having trouble with e-mail sending, I mean, the website is suposed to send a confirmation email after sign up, but it gets like text plain instead of HTML May someone help me, please? ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.