R
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("(e-mail address 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
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 address 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