By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,812 Members | 1,324 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,812 IT Pros & Developers. It's quick & easy.

OPERATOR '&' IS NOT DEFINED

P: n/a
Can somebody tell me why I get this message with the following code?

Compiler Error Message: BC30452: Operator '&' is not defined for types
'String' and 'System.Web.UI.WebControls.TextBox'.

<html>

<head>

<% @Import Namespace="System.Web.Mail" %>

<script language="VB" runat="server">

Sub btnSendFeedback_Click(sender as Object, e as EventArgs)

'Create an instance of the MailMessage class

Dim objMM as New MailMessage()

'Set the properties - send the email to the person who filled out the

'feedback form.

objMM.To = "xx*****@xxxxxxx.com"
objMM.From = "xx*****@xxxxxxx.com"

'send in html format

objMM.BodyFormat = MailFormat.html

'Set the priority - options are High, Low, and Normal

objMM.Priority = MailPriority.Normal

'Set the subject

objMM.Subject = "Accident Investigation Form"
'Set the body

objMM.Body = DateTime.Now + " HI " & _

"<html>" & vbCrLf & vbCrLf & _

"<head>" & vbCrLf & vbCrLf & _

"</head>"& vbCrLf & vbCrLf & _

"<body>" & vbCrLf & vbCrLf & _

Location where accident occurred:

Location.Text & _

"<br>"& _

Check1.Text & "." & vbCrLf & vbCrLf & _

vbCrLf &vbCrLf & _

Check2.Text & vbCrLf & _

"</td>" & vbCrLf & vbCrLf & _

"</body>" & vbCrLf & vbCrLf & _

"</html>"
'Specify to use the default Smtp Server

SmtpMail.SmtpServer = ""

'Now, to send the message, use the Send method of the SmtpMail class

SmtpMail.Send(objMM)

panelSendEmail.Visible = false

panelMailSent.Visible = true

End Sub

</script>

</head>
<body>

<table width="750" bgcolor="#E9EDF4" table border="1" cellpadding="3">

<h3><center><font face="Verdana">Wheeler's Accident Investigation
Form</font></h3>

<hr>

<%--__________________________________________________ __________________________--%>

<%--ROW 1--%>
<td width="250" valign="top">
<form runat="server">

<font face="Verdana" Size="2">

Location where accident occurred: <asp:textbox id="Location" runat=server
Width="200"/>

</td>

<td align="right" valign="top" width="225">
<font face="Verdana" Size="2">Employer's Premises

<asp:CheckBox id=Check1 Text="yes" runat="server" />

<asp:CheckBox id=Check2 Text="no" runat="server" />

<br>
Job site

<asp:CheckBox id=Check3 Text="yes" runat="server" />

<asp:CheckBox id=Check4 Text="no" runat="server" />
</td>

<td>

<font face="Verdana" Size="2">Date of accident</font><br>

<asp:textbox id="Date" runat=server Width="100"/>
</td>

<%--__________________________________________________ __________________________--%>

<%--ROW 2--%>
<tr<td>

<font face="Verdana" Size="2">Who was injured?</font><br>

<asp:textbox id="Who" runat=server width="200"/>

</td>

<td align= "left">

<font face="Verdana" Size="2">Employee <asp:CheckBox id=Check5
runat="server" />

<br>

Non-employee <asp:CheckBox id=Check6 runat="server" />
</td>

<td align="right"><font face="Verdana" Size="2">

Time of accident a.m. <asp:textbox id="am" runat=server Width="90"/>

p.m. <asp:textbox id="pm" runat=server Width="90"/>

</TD>

<%--__________________________________________________ __________________________--%>

<%--ROW 3--%>

<tr>

<td>

<font face="Verdana" Size="2">Date of Hire <br<asp:textbox id="Hiredate"
runat=server/>

</td>

<td>

<font face="Verdana" Size="2">Job Title or Occupation <br><asp:textbox
id="occupation" runat=server width="200"/>

</td>

<td>

<font face="Verdana" Size="2">How long has employee worked at job where
injury occurred?<br><asp:textbox id="lengthofjob" runat=server/>

</td>

<%--__________________________________________________ __________________________--%>

<%--Row 4--%>

&nbsp&nbsp

<p>
<asp:Label id=Label1 font-name="arial" font-size="10pt" runat="server"/>

<!Copied from /smirnof>

<asp:panel id="panelSendEmail" runat="server">

<%--asp:textbox id= runat="server" /--%>

<br>

<b>Your Message:</b><br>

<%--asp:textbox id="txtMessage" TextMode="MultiLine"

Columns="40" Rows="10" runat="server" /--%>

<p>

<asp:button runat="server" id="btnSendFeedback" Text="Send

Feedback!"

OnClick="btnSendFeedback_Click" />

</asp:panel>

<asp:panel id="panelMailSent" runat="server" Visible="False">

An email has been sent to the email address you specified.

Thanks!

</asp:panel>

</form>

</body>

</html>
May 10 '07 #1
Share this Question
Share on Google+
39 Replies


P: n/a
"dancer" <da****@microsoft.comwrote in message
news:uU*************@TK2MSFTNGP05.phx.gbl...
Can somebody tell me why I get this message with the following code?

Compiler Error Message: BC30452: Operator '&' is not defined for types
'String' and 'System.Web.UI.WebControls.TextBox'.
Normally that means you're trying to use the contents of an <asp:TextBox>
without specifying its .Text property

e.g. Location instead of Location.Text

However, I'm wondering if it might be because you've forgotten the double
quotes here:
"<body>" & vbCrLf & vbCrLf & _

Location where accident occurred:

Location.Text & _

--
http://www.markrae.net

May 10 '07 #2

P: n/a
You don't need to set the html/head/body tags within the HTML body
....and, in the VbCrLf thread, we established that you can't use VbCrLf in HTML.

Something else : you *must* put all the HTML content in ONE line.
You can't break the lines with code.

Get rid of all the "VbCrLf" and all the "&" and write all your HTML in a single line,
line-breaking the body's content with "<br />" or "<P... </P>" as needed.

Also, you can't insert Textbox controls into your HTML.

So, Check1.Text is out, too.

If you want to reference their content, after a user fills them out,
capture it to a variable and use that, before writing to the body.

insert :

Dim Check1 as String = Check1.Text
Dim Check2 as String = Check2.Text
Dim Location as String = Location.Text
before "Dim objMM as New MailMessage()"

and, when composing the body, use :

mail.Body="Hi, <p>The location where the accident occurred is :" & Location & "<br/>" & Check1 & "."
' etc.

You *can* use the & to reference text variables.
Notice the location of the quote marks.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"dancer" <da****@microsoft.comwrote in message news:uU*************@TK2MSFTNGP05.phx.gbl...
Can somebody tell me why I get this message with the following code?

Compiler Error Message: BC30452: Operator '&' is not defined for types 'String' and
'System.Web.UI.WebControls.TextBox'.

<html>

<head>

<% @Import Namespace="System.Web.Mail" %>

<script language="VB" runat="server">

Sub btnSendFeedback_Click(sender as Object, e as EventArgs)

'Create an instance of the MailMessage class

Dim objMM as New MailMessage()

'Set the properties - send the email to the person who filled out the

'feedback form.

objMM.To = "xx*****@xxxxxxx.com"
objMM.From = "xx*****@xxxxxxx.com"

'send in html format

objMM.BodyFormat = MailFormat.html

'Set the priority - options are High, Low, and Normal

objMM.Priority = MailPriority.Normal

'Set the subject

objMM.Subject = "Accident Investigation Form"
'Set the body

objMM.Body = DateTime.Now + " HI " & _

"<html>" & vbCrLf & vbCrLf & _

"<head>" & vbCrLf & vbCrLf & _

"</head>"& vbCrLf & vbCrLf & _

"<body>" & vbCrLf & vbCrLf & _

Location where accident occurred:

Location.Text & _

"<br>"& _
7Check1.Text & "." & vbCrLf & vbCrLf & _
>
vbCrLf &vbCrLf & _

Check2.Text & vbCrLf & _

"</td>" & vbCrLf & vbCrLf & _

"</body>" & vbCrLf & vbCrLf & _

"</html>"
'Specify to use the default Smtp Server

SmtpMail.SmtpServer = ""

'Now, to send the message, use the Send method of the SmtpMail class

SmtpMail.Send(objMM)

panelSendEmail.Visible = false

panelMailSent.Visible = true

End Sub

</script>

</head>
<body>

<table width="750" bgcolor="#E9EDF4" table border="1" cellpadding="3">

<h3><center><font face="Verdana">Wheeler's Accident Investigation Form</font></h3>

<hr>

<%--__________________________________________________ __________________________--%>

<%--ROW 1--%>
<td width="250" valign="top">
<form runat="server">

<font face="Verdana" Size="2">

Location where accident occurred: <asp:textbox id="Location" runat=server Width="200"/>

</td>

<td align="right" valign="top" width="225">
<font face="Verdana" Size="2">Employer's Premises

<asp:CheckBox id=Check1 Text="yes" runat="server" />

<asp:CheckBox id=Check2 Text="no" runat="server" />

<br>
Job site

<asp:CheckBox id=Check3 Text="yes" runat="server" />

<asp:CheckBox id=Check4 Text="no" runat="server" />
</td>

<td>

<font face="Verdana" Size="2">Date of accident</font><br>

<asp:textbox id="Date" runat=server Width="100"/>
</td>

<%--__________________________________________________ __________________________--%>

<%--ROW 2--%>
<tr<td>

<font face="Verdana" Size="2">Who was injured?</font><br>

<asp:textbox id="Who" runat=server width="200"/>

</td>

<td align= "left">

<font face="Verdana" Size="2">Employee <asp:CheckBox id=Check5 runat="server" />

<br>

Non-employee <asp:CheckBox id=Check6 runat="server" />
</td>

<td align="right"><font face="Verdana" Size="2">

Time of accident a.m. <asp:textbox id="am" runat=server Width="90"/>

p.m. <asp:textbox id="pm" runat=server Width="90"/>

</TD>

<%--__________________________________________________ __________________________--%>

<%--ROW 3--%>

<tr>

<td>

<font face="Verdana" Size="2">Date of Hire <br<asp:textbox id="Hiredate" runat=server/>

</td>

<td>

<font face="Verdana" Size="2">Job Title or Occupation <br><asp:textbox id="occupation"
runat=server width="200"/>

</td>

<td>

<font face="Verdana" Size="2">How long has employee worked at job where injury
occurred?<br><asp:textbox id="lengthofjob" runat=server/>

</td>

<%--__________________________________________________ __________________________--%>

<%--Row 4--%>

&nbsp&nbsp

<p>
<asp:Label id=Label1 font-name="arial" font-size="10pt" runat="server"/>

<!Copied from /smirnof>

<asp:panel id="panelSendEmail" runat="server">

<%--asp:textbox id= runat="server" /--%>

<br>

<b>Your Message:</b><br>

<%--asp:textbox id="txtMessage" TextMode="MultiLine"

Columns="40" Rows="10" runat="server" /--%>

<p>

<asp:button runat="server" id="btnSendFeedback" Text="Send

Feedback!"

OnClick="btnSendFeedback_Click" />

</asp:panel>

<asp:panel id="panelMailSent" runat="server" Visible="False">

An email has been sent to the email address you specified.

Thanks!

</asp:panel>

</form>

</body>

</html>


May 10 '07 #3

P: n/a
Location where accident occurred: should be "Location where accident
occured:" & _

And as you have a Location textbox the compiler see the location variable
and as you can't add a string and a textbox....

---
Patrice

"dancer" <da****@microsoft.coma écrit dans le message de news:
uU*************@TK2MSFTNGP05.phx.gbl...
Can somebody tell me why I get this message with the following code?

Compiler Error Message: BC30452: Operator '&' is not defined for types
'String' and 'System.Web.UI.WebControls.TextBox'.

<html>

<head>

<% @Import Namespace="System.Web.Mail" %>

<script language="VB" runat="server">

Sub btnSendFeedback_Click(sender as Object, e as EventArgs)

'Create an instance of the MailMessage class

Dim objMM as New MailMessage()

'Set the properties - send the email to the person who filled out the

'feedback form.

objMM.To = "xx*****@xxxxxxx.com"
objMM.From = "xx*****@xxxxxxx.com"

'send in html format

objMM.BodyFormat = MailFormat.html

'Set the priority - options are High, Low, and Normal

objMM.Priority = MailPriority.Normal

'Set the subject

objMM.Subject = "Accident Investigation Form"
'Set the body

objMM.Body = DateTime.Now + " HI " & _

"<html>" & vbCrLf & vbCrLf & _

"<head>" & vbCrLf & vbCrLf & _

"</head>"& vbCrLf & vbCrLf & _

"<body>" & vbCrLf & vbCrLf & _

Location where accident occurred:

Location.Text & _

"<br>"& _

Check1.Text & "." & vbCrLf & vbCrLf & _

vbCrLf &vbCrLf & _

Check2.Text & vbCrLf & _

"</td>" & vbCrLf & vbCrLf & _

"</body>" & vbCrLf & vbCrLf & _

"</html>"
'Specify to use the default Smtp Server

SmtpMail.SmtpServer = ""

'Now, to send the message, use the Send method of the SmtpMail class

SmtpMail.Send(objMM)

panelSendEmail.Visible = false

panelMailSent.Visible = true

End Sub

</script>

</head>
<body>

<table width="750" bgcolor="#E9EDF4" table border="1" cellpadding="3">

<h3><center><font face="Verdana">Wheeler's Accident Investigation
Form</font></h3>

<hr>

<%--__________________________________________________ __________________________--%>

<%--ROW 1--%>
<td width="250" valign="top">
<form runat="server">

<font face="Verdana" Size="2">

Location where accident occurred: <asp:textbox id="Location" runat=server
Width="200"/>

</td>

<td align="right" valign="top" width="225">
<font face="Verdana" Size="2">Employer's Premises

<asp:CheckBox id=Check1 Text="yes" runat="server" />

<asp:CheckBox id=Check2 Text="no" runat="server" />

<br>
Job site

<asp:CheckBox id=Check3 Text="yes" runat="server" />

<asp:CheckBox id=Check4 Text="no" runat="server" />
</td>

<td>

<font face="Verdana" Size="2">Date of accident</font><br>

<asp:textbox id="Date" runat=server Width="100"/>
</td>

<%--__________________________________________________ __________________________--%>

<%--ROW 2--%>
<tr<td>

<font face="Verdana" Size="2">Who was injured?</font><br>

<asp:textbox id="Who" runat=server width="200"/>

</td>

<td align= "left">

<font face="Verdana" Size="2">Employee <asp:CheckBox id=Check5
runat="server" />

<br>

Non-employee <asp:CheckBox id=Check6 runat="server" />
</td>

<td align="right"><font face="Verdana" Size="2">

Time of accident a.m. <asp:textbox id="am" runat=server Width="90"/>

p.m. <asp:textbox id="pm" runat=server Width="90"/>

</TD>

<%--__________________________________________________ __________________________--%>

<%--ROW 3--%>

<tr>

<td>

<font face="Verdana" Size="2">Date of Hire <br<asp:textbox id="Hiredate"
runat=server/>

</td>

<td>

<font face="Verdana" Size="2">Job Title or Occupation <br><asp:textbox
id="occupation" runat=server width="200"/>

</td>

<td>

<font face="Verdana" Size="2">How long has employee worked at job where
injury occurred?<br><asp:textbox id="lengthofjob" runat=server/>

</td>

<%--__________________________________________________ __________________________--%>

<%--Row 4--%>

&nbsp&nbsp

<p>
<asp:Label id=Label1 font-name="arial" font-size="10pt" runat="server"/>

<!Copied from /smirnof>

<asp:panel id="panelSendEmail" runat="server">

<%--asp:textbox id= runat="server" /--%>

<br>

<b>Your Message:</b><br>

<%--asp:textbox id="txtMessage" TextMode="MultiLine"

Columns="40" Rows="10" runat="server" /--%>

<p>

<asp:button runat="server" id="btnSendFeedback" Text="Send

Feedback!"

OnClick="btnSendFeedback_Click" />

</asp:panel>

<asp:panel id="panelMailSent" runat="server" Visible="False">

An email has been sent to the email address you specified.

Thanks!

</asp:panel>

</form>

</body>

</html>


May 10 '07 #4

P: n/a
Hi Juan,

What is the difference in what I am trying to do and this? Why can THEY
break up the HTML content into different lines?

email_html.aspx
--------------------------------------------------------------------------------

<%@ Page Language="VB" ClientTarget="downlevel" %>
<%@ Import Namespace="System.Web.Mail" %>
<script language="VB" runat="server">
Sub btnSendMail_OnClick(Source As Object, E As EventArgs)
Dim myMessage As New MailMessage
Dim myMail As SmtpMail
Dim strEmail As String

If Page.IsValid() Then
strEmail = txtEmail.Text

'myMessage.From = "webmaster@" & Request.ServerVariables("SERVER_NAME")
myMessage.From = "we*******@asp101.com"
myMessage.To = strEmail
myMessage.Subject = "E-mail Sample (HTML) from ASP 101!"

' This is the magic line. Without this the message will just appear
' as plain HTML and won't be rendered by the recipient's email client.
' It'd be as if they did "View Source" on a web page.
MyMessage.BodyFormat = MailFormat.Html

' This is multi-lined simply for readability.
' Notice that it is a properly formatted HTML
' message and not just plain text like most email.
' A lot of people have asked how to use form data
' in the emails so I added an example of including
' the entered address in the body of the email.
myMessage.Body = "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0
Transitional//EN"">" & vbCrLf _
& "<html>" & vbCrLf _
& "<head>" & vbCrLf _
& " <title>Sample Message From ASP 101</title>" & vbCrLf _
& " <meta http-equiv=Content-Type content=""text/html;
charset=iso-8859-1"">" & vbCrLf _
& "</head>" & vbCrLf _
& "<body bgcolor=""#FFFFCC"">" & vbCrLf _
& " <h2>Sample Message From ASP 101</h2>" & vbCrLf _
& " <p>" & vbCrLf _
& " This message was sent from a sample at" & vbCrLf _
& " <a href=""http://www.asp101.com"">ASP 101</a>." & vbCrLf _
& " It is used to show people how to send HTML" & vbCrLf _
& " formatted email from an ASP.NET page." & vbCrLf _
& " If you did not request this email yourself," & vbCrLf _
& " your address was entered by one of our" & vbCrLf _
& " visitors." & vbCrLf _
& " <strong>" & vbCrLf _
& " We do not store these e-mail addresses." & vbCrLf _
& " </strong>" & vbCrLf _
& " </p>" & vbCrLf _
& " <p><font size=""-1"">Please address all concerns to
we*******@asp101.com.</font></p>" & vbCrLf _
& " <p><font size=""-1"">This message was sent to: " & strEmail &
"</font></p>" & vbCrLf _
& "</body>" & vbCrLf _
& "</html>" & vbCrLf

' Doesn't have to be local... just enter your
' SMTP server's name or ip address!
myMail.SmtpServer = "localhost"
myMail.Send(myMessage)

frmEmail.Visible = False
lblUserMessage.Text = "An HTML-formatted email message has been sent to "
& strEmail & "."
End If
End Sub
</script>

<html>
<head>
<title>ASP.NET Email (HTML Format) Sample</title>
</head>
<body>

<asp:Label id="lblUserMessage" text="Enter your e-mail address:"
runat="server" />
<form method="post" id="frmEmail" runat="server">
<asp:TextBox id="txtEmail" size="30" runat="server" />
<asp:RequiredFieldValidator runat="server"
id="validEmailRequired" ControlToValidate="txtEmail"
errormessage="Please enter an email address."
display="Dynamic" />
<asp:RegularExpressionValidator runat="server"
id="validEmailRegExp" ControlToValidate="txtEmail"
ValidationExpression="^[\w-]+@[\w-]+\.(com|net|org|edu|mil)$"
errormessage="Please enter a valid email address."
Display="Dynamic" />

<asp:Button id="btnSendMail" text="Send Mail!"
OnClick="btnSendMail_OnClick" runat="server" />
</form>

<hr />

<p>
Click <a href="http://www.asp101.com/samples/email_html_aspx.asp">here</a>
to read about and download the source code.
</p>

</body>
</html>
--------------------------------------------------------------------------------

"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
You don't need to set the html/head/body tags within the HTML body
...and, in the VbCrLf thread, we established that you can't use VbCrLf in
HTML.

Something else : you *must* put all the HTML content in ONE line.
You can't break the lines with code.

Get rid of all the "VbCrLf" and all the "&" and write all your HTML in a
single line,
line-breaking the body's content with "<br />" or "<P... </P>" as
needed.

Also, you can't insert Textbox controls into your HTML.

So, Check1.Text is out, too.

If you want to reference their content, after a user fills them out,
capture it to a variable and use that, before writing to the body.

insert :

Dim Check1 as String = Check1.Text
Dim Check2 as String = Check2.Text
Dim Location as String = Location.Text
before "Dim objMM as New MailMessage()"

and, when composing the body, use :

mail.Body="Hi, <p>The location where the accident occurred is :" &
Location & "<br/>" & Check1 & "."
' etc.

You *can* use the & to reference text variables.
Notice the location of the quote marks.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"dancer" <da****@microsoft.comwrote in message
news:uU*************@TK2MSFTNGP05.phx.gbl...
>Can somebody tell me why I get this message with the following code?

Compiler Error Message: BC30452: Operator '&' is not defined for types
'String' and
'System.Web.UI.WebControls.TextBox'.

<html>

<head>

<% @Import Namespace="System.Web.Mail" %>

<script language="VB" runat="server">

Sub btnSendFeedback_Click(sender as Object, e as EventArgs)

'Create an instance of the MailMessage class

Dim objMM as New MailMessage()

'Set the properties - send the email to the person who filled out the

'feedback form.

objMM.To = "xx*****@xxxxxxx.com"
objMM.From = "xx*****@xxxxxxx.com"

'send in html format

objMM.BodyFormat = MailFormat.html

'Set the priority - options are High, Low, and Normal

objMM.Priority = MailPriority.Normal

'Set the subject

objMM.Subject = "Accident Investigation Form"
'Set the body

objMM.Body = DateTime.Now + " HI " & _

"<html>" & vbCrLf & vbCrLf & _

"<head>" & vbCrLf & vbCrLf & _

"</head>"& vbCrLf & vbCrLf & _

"<body>" & vbCrLf & vbCrLf & _

Location where accident occurred:

Location.Text & _

"<br>"& _
7Check1.Text & "." & vbCrLf & vbCrLf & _
>>
vbCrLf &vbCrLf & _

Check2.Text & vbCrLf & _

"</td>" & vbCrLf & vbCrLf & _

"</body>" & vbCrLf & vbCrLf & _

"</html>"
'Specify to use the default Smtp Server

SmtpMail.SmtpServer = ""

'Now, to send the message, use the Send method of the SmtpMail class

SmtpMail.Send(objMM)

panelSendEmail.Visible = false

panelMailSent.Visible = true

End Sub

</script>

</head>
<body>

<table width="750" bgcolor="#E9EDF4" table border="1" cellpadding="3">

<h3><center><font face="Verdana">Wheeler's Accident Investigation
Form</font></h3>

<hr>

<%--__________________________________________________ __________________________--%>

<%--ROW 1--%>
<td width="250" valign="top">
<form runat="server">

<font face="Verdana" Size="2">

Location where accident occurred: <asp:textbox id="Location" runat=server
Width="200"/>

</td>

<td align="right" valign="top" width="225">
<font face="Verdana" Size="2">Employer's Premises

<asp:CheckBox id=Check1 Text="yes" runat="server" />

<asp:CheckBox id=Check2 Text="no" runat="server" />

<br>
Job site

<asp:CheckBox id=Check3 Text="yes" runat="server" />

<asp:CheckBox id=Check4 Text="no" runat="server" />
</td>

<td>

<font face="Verdana" Size="2">Date of accident</font><br>

<asp:textbox id="Date" runat=server Width="100"/>
</td>

<%--__________________________________________________ __________________________--%>

<%--ROW 2--%>
<tr<td>

<font face="Verdana" Size="2">Who was injured?</font><br>

<asp:textbox id="Who" runat=server width="200"/>

</td>

<td align= "left">

<font face="Verdana" Size="2">Employee <asp:CheckBox id=Check5
runat="server" />

<br>

Non-employee <asp:CheckBox id=Check6 runat="server" />
</td>

<td align="right"><font face="Verdana" Size="2">

Time of accident a.m. <asp:textbox id="am" runat=server Width="90"/>

p.m. <asp:textbox id="pm" runat=server Width="90"/>

</TD>

<%--__________________________________________________ __________________________--%>

<%--ROW 3--%>

<tr>

<td>

<font face="Verdana" Size="2">Date of Hire <br<asp:textbox
id="Hiredate" runat=server/>

</td>

<td>

<font face="Verdana" Size="2">Job Title or Occupation <br><asp:textbox
id="occupation"
runat=server width="200"/>

</td>

<td>

<font face="Verdana" Size="2">How long has employee worked at job where
injury
occurred?<br><asp:textbox id="lengthofjob" runat=server/>

</td>

<%--__________________________________________________ __________________________--%>

<%--Row 4--%>

&nbsp&nbsp

<p>
<asp:Label id=Label1 font-name="arial" font-size="10pt" runat="server"/>

<!Copied from /smirnof>

<asp:panel id="panelSendEmail" runat="server">

<%--asp:textbox id= runat="server" /--%>

<br>

<b>Your Message:</b><br>

<%--asp:textbox id="txtMessage" TextMode="MultiLine"

Columns="40" Rows="10" runat="server" /--%>

<p>

<asp:button runat="server" id="btnSendFeedback" Text="Send

Feedback!"

OnClick="btnSendFeedback_Click" />

</asp:panel>

<asp:panel id="panelMailSent" runat="server" Visible="False">

An email has been sent to the email address you specified.

Thanks!

</asp:panel>

</form>

</body>

</html>



May 10 '07 #5

P: n/a
"dancer" <da****@microsoft.comwrote in message
news:uH**************@TK2MSFTNGP04.phx.gbl...

As an aside, you appear to have attached a binary file to your post - my
newsreader is configured not to download posts with binary attachments,
which means that I (and anyone else who has also set this configuration
option) won't see your post...

May 10 '07 #6

P: n/a
What should I do? I copied code from ASP101 to ask a question about it.
"Mark Rae" <ma**@markNOSPAMrae.netwrote in message
news:u8**************@TK2MSFTNGP06.phx.gbl...
"dancer" <da****@microsoft.comwrote in message
news:uH**************@TK2MSFTNGP04.phx.gbl...

As an aside, you appear to have attached a binary file to your post - my
newsreader is configured not to download posts with binary attachments,
which means that I (and anyone else who has also set this configuration
option) won't see your post...

May 10 '07 #7

P: n/a
Mark,
Can you see this? I didn't include the logo on the page.

I am asking Juan what is the difference in what I am trying to accomplish
and what they are doing. Why can THEY break the HTML content into different
lines?

<%@ Page Language="VB" ClientTarget="downlevel" %>
<%@ Import Namespace="System.Web.Mail" %>
<script language="VB" runat="server">
Sub btnSendMail_OnClick(Source As Object, E As EventArgs)
Dim myMessage As New MailMessage
Dim myMail As SmtpMail
Dim strEmail As String

If Page.IsValid() Then
strEmail = txtEmail.Text

'myMessage.From = "webmaster@" & Request.ServerVariables("SERVER_NAME")
myMessage.From = "we*******@asp101.com"
myMessage.To = strEmail
myMessage.Subject = "E-mail Sample (HTML) from ASP 101!"

' This is the magic line. Without this the message will just appear
' as plain HTML and won't be rendered by the recipient's email client.
' It'd be as if they did "View Source" on a web page.
MyMessage.BodyFormat = MailFormat.Html

' This is multi-lined simply for readability.
' Notice that it is a properly formatted HTML
' message and not just plain text like most email.
' A lot of people have asked how to use form data
' in the emails so I added an example of including
' the entered address in the body of the email.
myMessage.Body = "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0
Transitional//EN"">" & vbCrLf _
& "<html>" & vbCrLf _
& "<head>" & vbCrLf _
& " <title>Sample Message From ASP 101</title>" & vbCrLf _
& " <meta http-equiv=Content-Type content=""text/html;
charset=iso-8859-1"">" & vbCrLf _
& "</head>" & vbCrLf _
& "<body bgcolor=""#FFFFCC"">" & vbCrLf _
& " <h2>Sample Message From ASP 101</h2>" & vbCrLf _
& " <p>" & vbCrLf _
& " This message was sent from a sample at" & vbCrLf _
& " <a href=""http://www.asp101.com"">ASP 101</a>." & vbCrLf _
& " It is used to show people how to send HTML" & vbCrLf _
& " formatted email from an ASP.NET page." & vbCrLf _
& " If you did not request this email yourself," & vbCrLf _
& " your address was entered by one of our" & vbCrLf _
& " visitors." & vbCrLf _
& " <strong>" & vbCrLf _
& " We do not store these e-mail addresses." & vbCrLf _
& " </strong>" & vbCrLf _
& " </p>" & vbCrLf _
& " <p><font size=""-1"">Please address all concerns to
we*******@asp101.com.</font></p>" & vbCrLf _
& " <p><font size=""-1"">This message was sent to: " & strEmail &
"</font></p>" & vbCrLf _
& "</body>" & vbCrLf _
& "</html>" & vbCrLf

' Doesn't have to be local... just enter your
' SMTP server's name or ip address!
myMail.SmtpServer = "localhost"
myMail.Send(myMessage)

frmEmail.Visible = False
lblUserMessage.Text = "An HTML-formatted email message has been sent to "
& strEmail & "."
End If
End Sub
</script>

<html>
<head>
<title>ASP.NET Email (HTML Format) Sample</title>
</head>
<body>

<asp:Label id="lblUserMessage" text="Enter your e-mail address:"
runat="server" />
<form method="post" id="frmEmail" runat="server">
<asp:TextBox id="txtEmail" size="30" runat="server" />
<asp:RequiredFieldValidator runat="server"
id="validEmailRequired" ControlToValidate="txtEmail"
errormessage="Please enter an email address."
display="Dynamic" />
<asp:RegularExpressionValidator runat="server"
id="validEmailRegExp" ControlToValidate="txtEmail"
ValidationExpression="^[\w-]+@[\w-]+\.(com|net|org|edu|mil)$"
errormessage="Please enter a valid email address."
Display="Dynamic" />

<asp:Button id="btnSendMail" text="Send Mail!"
OnClick="btnSendMail_OnClick" runat="server" />
</form>

<hr />

<p>
Click <a href="http://www.asp101.com/samples/email_html_aspx.asp">here</a>
to read about and download the source code.
</p>

</body>
</html>


"Mark Rae" <ma**@markNOSPAMrae.netwrote in message
news:u8**************@TK2MSFTNGP06.phx.gbl...
"dancer" <da****@microsoft.comwrote in message
news:uH**************@TK2MSFTNGP04.phx.gbl...

As an aside, you appear to have attached a binary file to your post - my
newsreader is configured not to download posts with binary attachments,
which means that I (and anyone else who has also set this configuration
option) won't see your post...

May 10 '07 #8

P: n/a
The vbCrLf are purely to ensure that the line is not too long when
generated. There is a problem with over long lines that when they do
eventually wrap, it can disrupt your formatted email.

You will note that there are no br tags, but there are p tags <pand </p>.
These are what cause <P>aragraph breaks. (Actually, they are for new
paragraphs rather than breaking paragraphs).

Does this answer your question?

(Note, you probably can't press "Yes" below as you probably can't see it. If
you can, then you have better eyes than me, as I can't see it. :-)

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available

"dancer" <da****@microsoft.comwrote in message
news:uH**************@TK2MSFTNGP04.phx.gbl...
Hi Juan,

What is the difference in what I am trying to do and this? Why can THEY
break up the HTML content into different lines?

email_html.aspx
--------------------------------------------------------------------------------

<%@ Page Language="VB" ClientTarget="downlevel" %>
<%@ Import Namespace="System.Web.Mail" %>
<script language="VB" runat="server">
Sub btnSendMail_OnClick(Source As Object, E As EventArgs)
Dim myMessage As New MailMessage
Dim myMail As SmtpMail
Dim strEmail As String

If Page.IsValid() Then
strEmail = txtEmail.Text

'myMessage.From = "webmaster@" & Request.ServerVariables("SERVER_NAME")
myMessage.From = "we*******@asp101.com"
myMessage.To = strEmail
myMessage.Subject = "E-mail Sample (HTML) from ASP 101!"

' This is the magic line. Without this the message will just appear
' as plain HTML and won't be rendered by the recipient's email client.
' It'd be as if they did "View Source" on a web page.
MyMessage.BodyFormat = MailFormat.Html

' This is multi-lined simply for readability.
' Notice that it is a properly formatted HTML
' message and not just plain text like most email.
' A lot of people have asked how to use form data
' in the emails so I added an example of including
' the entered address in the body of the email.
myMessage.Body = "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0
Transitional//EN"">" & vbCrLf _
& "<html>" & vbCrLf _
& "<head>" & vbCrLf _
& " <title>Sample Message From ASP 101</title>" & vbCrLf _
& " <meta http-equiv=Content-Type content=""text/html;
charset=iso-8859-1"">" & vbCrLf _
& "</head>" & vbCrLf _
& "<body bgcolor=""#FFFFCC"">" & vbCrLf _
& " <h2>Sample Message From ASP 101</h2>" & vbCrLf _
& " <p>" & vbCrLf _
& " This message was sent from a sample at" & vbCrLf _
& " <a href=""http://www.asp101.com"">ASP 101</a>." & vbCrLf _
& " It is used to show people how to send HTML" & vbCrLf _
& " formatted email from an ASP.NET page." & vbCrLf _
& " If you did not request this email yourself," & vbCrLf _
& " your address was entered by one of our" & vbCrLf _
& " visitors." & vbCrLf _
& " <strong>" & vbCrLf _
& " We do not store these e-mail addresses." & vbCrLf _
& " </strong>" & vbCrLf _
& " </p>" & vbCrLf _
& " <p><font size=""-1"">Please address all concerns to
we*******@asp101.com.</font></p>" & vbCrLf _
& " <p><font size=""-1"">This message was sent to: " & strEmail &
"</font></p>" & vbCrLf _
& "</body>" & vbCrLf _
& "</html>" & vbCrLf

' Doesn't have to be local... just enter your
' SMTP server's name or ip address!
myMail.SmtpServer = "localhost"
myMail.Send(myMessage)

frmEmail.Visible = False
lblUserMessage.Text = "An HTML-formatted email message has been sent to "
& strEmail & "."
End If
End Sub
</script>

<html>
<head>
<title>ASP.NET Email (HTML Format) Sample</title>
</head>
<body>

<asp:Label id="lblUserMessage" text="Enter your e-mail address:"
runat="server" />
<form method="post" id="frmEmail" runat="server">
<asp:TextBox id="txtEmail" size="30" runat="server" />
<asp:RequiredFieldValidator runat="server"
id="validEmailRequired" ControlToValidate="txtEmail"
errormessage="Please enter an email address."
display="Dynamic" />
<asp:RegularExpressionValidator runat="server"
id="validEmailRegExp" ControlToValidate="txtEmail"
ValidationExpression="^[\w-]+@[\w-]+\.(com|net|org|edu|mil)$"
errormessage="Please enter a valid email address."
Display="Dynamic" />

<asp:Button id="btnSendMail" text="Send Mail!"
OnClick="btnSendMail_OnClick" runat="server" />
</form>

<hr />

<p>
Click <a href="http://www.asp101.com/samples/email_html_aspx.asp">here</a>
to read about and download the source code.
</p>

</body>
</html>
--------------------------------------------------------------------------------

"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>You don't need to set the html/head/body tags within the HTML body
...and, in the VbCrLf thread, we established that you can't use VbCrLf in
HTML.

Something else : you *must* put all the HTML content in ONE line.
You can't break the lines with code.

Get rid of all the "VbCrLf" and all the "&" and write all your HTML in a
single line,
line-breaking the body's content with "<br />" or "<P... </P>" as
needed.

Also, you can't insert Textbox controls into your HTML.

So, Check1.Text is out, too.

If you want to reference their content, after a user fills them out,
capture it to a variable and use that, before writing to the body.

insert :

Dim Check1 as String = Check1.Text
Dim Check2 as String = Check2.Text
Dim Location as String = Location.Text
before "Dim objMM as New MailMessage()"

and, when composing the body, use :

mail.Body="Hi, <p>The location where the accident occurred is :" &
Location & "<br/>" & Check1 & "."
' etc.

You *can* use the & to reference text variables.
Notice the location of the quote marks.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"dancer" <da****@microsoft.comwrote in message
news:uU*************@TK2MSFTNGP05.phx.gbl...
>>Can somebody tell me why I get this message with the following code?

Compiler Error Message: BC30452: Operator '&' is not defined for types
'String' and
'System.Web.UI.WebControls.TextBox'.

<html>

<head>

<% @Import Namespace="System.Web.Mail" %>

<script language="VB" runat="server">

Sub btnSendFeedback_Click(sender as Object, e as EventArgs)

'Create an instance of the MailMessage class

Dim objMM as New MailMessage()

'Set the properties - send the email to the person who filled out the

'feedback form.

objMM.To = "xx*****@xxxxxxx.com"
objMM.From = "xx*****@xxxxxxx.com"

'send in html format

objMM.BodyFormat = MailFormat.html

'Set the priority - options are High, Low, and Normal

objMM.Priority = MailPriority.Normal

'Set the subject

objMM.Subject = "Accident Investigation Form"
'Set the body

objMM.Body = DateTime.Now + " HI " & _

"<html>" & vbCrLf & vbCrLf & _

"<head>" & vbCrLf & vbCrLf & _

"</head>"& vbCrLf & vbCrLf & _

"<body>" & vbCrLf & vbCrLf & _

Location where accident occurred:

Location.Text & _

"<br>"& _
7Check1.Text & "." & vbCrLf & vbCrLf & _
>>>
vbCrLf &vbCrLf & _

Check2.Text & vbCrLf & _

"</td>" & vbCrLf & vbCrLf & _

"</body>" & vbCrLf & vbCrLf & _

"</html>"
'Specify to use the default Smtp Server

SmtpMail.SmtpServer = ""

'Now, to send the message, use the Send method of the SmtpMail class

SmtpMail.Send(objMM)

panelSendEmail.Visible = false

panelMailSent.Visible = true

End Sub

</script>

</head>
<body>

<table width="750" bgcolor="#E9EDF4" table border="1" cellpadding="3">

<h3><center><font face="Verdana">Wheeler's Accident Investigation
Form</font></h3>

<hr>

<%--__________________________________________________ __________________________--%>

<%--ROW 1--%>
<td width="250" valign="top">
<form runat="server">

<font face="Verdana" Size="2">

Location where accident occurred: <asp:textbox id="Location"
runat=server Width="200"/>

</td>

<td align="right" valign="top" width="225">
<font face="Verdana" Size="2">Employer's Premises

<asp:CheckBox id=Check1 Text="yes" runat="server" />

<asp:CheckBox id=Check2 Text="no" runat="server" />

<br>
Job site

<asp:CheckBox id=Check3 Text="yes" runat="server" />

<asp:CheckBox id=Check4 Text="no" runat="server" />
</td>

<td>

<font face="Verdana" Size="2">Date of accident</font><br>

<asp:textbox id="Date" runat=server Width="100"/>
</td>

<%--__________________________________________________ __________________________--%>

<%--ROW 2--%>
<tr<td>

<font face="Verdana" Size="2">Who was injured?</font><br>

<asp:textbox id="Who" runat=server width="200"/>

</td>

<td align= "left">

<font face="Verdana" Size="2">Employee <asp:CheckBox id=Check5
runat="server" />

<br>

Non-employee <asp:CheckBox id=Check6 runat="server" />
</td>

<td align="right"><font face="Verdana" Size="2">

Time of accident a.m. <asp:textbox id="am" runat=server Width="90"/>

p.m. <asp:textbox id="pm" runat=server Width="90"/>

</TD>

<%--__________________________________________________ __________________________--%>

<%--ROW 3--%>

<tr>

<td>

<font face="Verdana" Size="2">Date of Hire <br<asp:textbox
id="Hiredate" runat=server/>

</td>

<td>

<font face="Verdana" Size="2">Job Title or Occupation <br><asp:textbox
id="occupation"
runat=server width="200"/>

</td>

<td>

<font face="Verdana" Size="2">How long has employee worked at job where
injury
occurred?<br><asp:textbox id="lengthofjob" runat=server/>

</td>

<%--__________________________________________________ __________________________--%>

<%--Row 4--%>

&nbsp&nbsp

<p>
<asp:Label id=Label1 font-name="arial" font-size="10pt" runat="server"/>

<!Copied from /smirnof>

<asp:panel id="panelSendEmail" runat="server">

<%--asp:textbox id= runat="server" /--%>

<br>

<b>Your Message:</b><br>

<%--asp:textbox id="txtMessage" TextMode="MultiLine"

Columns="40" Rows="10" runat="server" /--%>

<p>

<asp:button runat="server" id="btnSendFeedback" Text="Send

Feedback!"

OnClick="btnSendFeedback_Click" />

</asp:panel>

<asp:panel id="panelMailSent" runat="server" Visible="False">

An email has been sent to the email address you specified.

Thanks!

</asp:panel>

</form>

</body>

</html>





May 10 '07 #9

P: n/a
David,

Not exactly does this answer my question. Could you please check out Juan's
answer to my first post on this subject and help me understand, since I was
copying my code from this code.

Thank you.
"David" <da*****************@revilloc.REMOVETHIS.comwrot e in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
The vbCrLf are purely to ensure that the line is not too long when
generated. There is a problem with over long lines that when they do
eventually wrap, it can disrupt your formatted email.

You will note that there are no br tags, but there are p tags <pand
</p>. These are what cause <P>aragraph breaks. (Actually, they are for new
paragraphs rather than breaking paragraphs).

Does this answer your question?

(Note, you probably can't press "Yes" below as you probably can't see it.
If you can, then you have better eyes than me, as I can't see it. :-)

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available

"dancer" <da****@microsoft.comwrote in message
news:uH**************@TK2MSFTNGP04.phx.gbl...
>Hi Juan,

What is the difference in what I am trying to do and this? Why can THEY
break up the HTML content into different lines?

email_html.aspx
--------------------------------------------------------------------------------

<%@ Page Language="VB" ClientTarget="downlevel" %>
<%@ Import Namespace="System.Web.Mail" %>
<script language="VB" runat="server">
Sub btnSendMail_OnClick(Source As Object, E As EventArgs)
Dim myMessage As New MailMessage
Dim myMail As SmtpMail
Dim strEmail As String

If Page.IsValid() Then
strEmail = txtEmail.Text

'myMessage.From = "webmaster@" & Request.ServerVariables("SERVER_NAME")
myMessage.From = "we*******@asp101.com"
myMessage.To = strEmail
myMessage.Subject = "E-mail Sample (HTML) from ASP 101!"

' This is the magic line. Without this the message will just appear
' as plain HTML and won't be rendered by the recipient's email client.
' It'd be as if they did "View Source" on a web page.
MyMessage.BodyFormat = MailFormat.Html

' This is multi-lined simply for readability.
' Notice that it is a properly formatted HTML
' message and not just plain text like most email.
' A lot of people have asked how to use form data
' in the emails so I added an example of including
' the entered address in the body of the email.
myMessage.Body = "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0
Transitional//EN"">" & vbCrLf _
& "<html>" & vbCrLf _
& "<head>" & vbCrLf _
& " <title>Sample Message From ASP 101</title>" & vbCrLf _
& " <meta http-equiv=Content-Type content=""text/html;
charset=iso-8859-1"">" & vbCrLf _
& "</head>" & vbCrLf _
& "<body bgcolor=""#FFFFCC"">" & vbCrLf _
& " <h2>Sample Message From ASP 101</h2>" & vbCrLf _
& " <p>" & vbCrLf _
& " This message was sent from a sample at" & vbCrLf _
& " <a href=""http://www.asp101.com"">ASP 101</a>." & vbCrLf _
& " It is used to show people how to send HTML" & vbCrLf _
& " formatted email from an ASP.NET page." & vbCrLf _
& " If you did not request this email yourself," & vbCrLf _
& " your address was entered by one of our" & vbCrLf _
& " visitors." & vbCrLf _
& " <strong>" & vbCrLf _
& " We do not store these e-mail addresses." & vbCrLf _
& " </strong>" & vbCrLf _
& " </p>" & vbCrLf _
& " <p><font size=""-1"">Please address all concerns to
we*******@asp101.com.</font></p>" & vbCrLf _
& " <p><font size=""-1"">This message was sent to: " & strEmail &
"</font></p>" & vbCrLf _
& "</body>" & vbCrLf _
& "</html>" & vbCrLf

' Doesn't have to be local... just enter your
' SMTP server's name or ip address!
myMail.SmtpServer = "localhost"
myMail.Send(myMessage)

frmEmail.Visible = False
lblUserMessage.Text = "An HTML-formatted email message has been sent to "
& strEmail & "."
End If
End Sub
</script>

<html>
<head>
<title>ASP.NET Email (HTML Format) Sample</title>
</head>
<body>

<asp:Label id="lblUserMessage" text="Enter your e-mail address:"
runat="server" />
<form method="post" id="frmEmail" runat="server">
<asp:TextBox id="txtEmail" size="30" runat="server" />
<asp:RequiredFieldValidator runat="server"
id="validEmailRequired" ControlToValidate="txtEmail"
errormessage="Please enter an email address."
display="Dynamic" />
<asp:RegularExpressionValidator runat="server"
id="validEmailRegExp" ControlToValidate="txtEmail"
ValidationExpression="^[\w-]+@[\w-]+\.(com|net|org|edu|mil)$"
errormessage="Please enter a valid email address."
Display="Dynamic" />

<asp:Button id="btnSendMail" text="Send Mail!"
OnClick="btnSendMail_OnClick" runat="server" />
</form>

<hr />

<p>
Click <a
href="http://www.asp101.com/samples/email_html_aspx.asp">here</ato read
about and download the source code.
</p>

</body>
</html>
--------------------------------------------------------------------------------

"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>>You don't need to set the html/head/body tags within the HTML body
...and, in the VbCrLf thread, we established that you can't use VbCrLf
in HTML.

Something else : you *must* put all the HTML content in ONE line.
You can't break the lines with code.

Get rid of all the "VbCrLf" and all the "&" and write all your HTML in a
single line,
line-breaking the body's content with "<br />" or "<P... </P>" as
needed.

Also, you can't insert Textbox controls into your HTML.

So, Check1.Text is out, too.

If you want to reference their content, after a user fills them out,
capture it to a variable and use that, before writing to the body.

insert :

Dim Check1 as String = Check1.Text
Dim Check2 as String = Check2.Text
Dim Location as String = Location.Text
before "Dim objMM as New MailMessage()"

and, when composing the body, use :

mail.Body="Hi, <p>The location where the accident occurred is :" &
Location & "<br/>" & Check1 & "."
' etc.

You *can* use the & to reference text variables.
Notice the location of the quote marks.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"dancer" <da****@microsoft.comwrote in message
news:uU*************@TK2MSFTNGP05.phx.gbl...
Can somebody tell me why I get this message with the following code?

Compiler Error Message: BC30452: Operator '&' is not defined for types
'String' and
'System.Web.UI.WebControls.TextBox'.

<html>

<head>

<% @Import Namespace="System.Web.Mail" %>

<script language="VB" runat="server">

Sub btnSendFeedback_Click(sender as Object, e as EventArgs)

'Create an instance of the MailMessage class

Dim objMM as New MailMessage()

'Set the properties - send the email to the person who filled out the

'feedback form.

objMM.To = "xx*****@xxxxxxx.com"
objMM.From = "xx*****@xxxxxxx.com"

'send in html format

objMM.BodyFormat = MailFormat.html

'Set the priority - options are High, Low, and Normal

objMM.Priority = MailPriority.Normal

'Set the subject

objMM.Subject = "Accident Investigation Form"
'Set the body

objMM.Body = DateTime.Now + " HI " & _

"<html>" & vbCrLf & vbCrLf & _

"<head>" & vbCrLf & vbCrLf & _

"</head>"& vbCrLf & vbCrLf & _

"<body>" & vbCrLf & vbCrLf & _

Location where accident occurred:

Location.Text & _

"<br>"& _

7Check1.Text & "." & vbCrLf & vbCrLf & _

vbCrLf &vbCrLf & _

Check2.Text & vbCrLf & _

"</td>" & vbCrLf & vbCrLf & _

"</body>" & vbCrLf & vbCrLf & _

"</html>"
'Specify to use the default Smtp Server

SmtpMail.SmtpServer = ""

'Now, to send the message, use the Send method of the SmtpMail class

SmtpMail.Send(objMM)

panelSendEmail.Visible = false

panelMailSent.Visible = true

End Sub

</script>

</head>
<body>

<table width="750" bgcolor="#E9EDF4" table border="1" cellpadding="3">

<h3><center><font face="Verdana">Wheeler's Accident Investigation
Form</font></h3>

<hr>

<%--__________________________________________________ __________________________--%>

<%--ROW 1--%>
<td width="250" valign="top">
<form runat="server">

<font face="Verdana" Size="2">

Location where accident occurred: <asp:textbox id="Location"
runat=server Width="200"/>

</td>

<td align="right" valign="top" width="225">
<font face="Verdana" Size="2">Employer's Premises

<asp:CheckBox id=Check1 Text="yes" runat="server" />

<asp:CheckBox id=Check2 Text="no" runat="server" />

<br>
Job site

<asp:CheckBox id=Check3 Text="yes" runat="server" />

<asp:CheckBox id=Check4 Text="no" runat="server" />
</td>

<td>

<font face="Verdana" Size="2">Date of accident</font><br>

<asp:textbox id="Date" runat=server Width="100"/>
</td>

<%--__________________________________________________ __________________________--%>

<%--ROW 2--%>
<tr<td>

<font face="Verdana" Size="2">Who was injured?</font><br>

<asp:textbox id="Who" runat=server width="200"/>

</td>

<td align= "left">

<font face="Verdana" Size="2">Employee <asp:CheckBox id=Check5
runat="server" />

<br>

Non-employee <asp:CheckBox id=Check6 runat="server" />
</td>

<td align="right"><font face="Verdana" Size="2">

Time of accident a.m. <asp:textbox id="am" runat=server Width="90"/>

p.m. <asp:textbox id="pm" runat=server Width="90"/>

</TD>

<%--__________________________________________________ __________________________--%>

<%--ROW 3--%>

<tr>

<td>

<font face="Verdana" Size="2">Date of Hire <br<asp:textbox
id="Hiredate" runat=server/>

</td>

<td>

<font face="Verdana" Size="2">Job Title or Occupation <br><asp:textbox
id="occupation"
runat=server width="200"/>

</td>

<td>

<font face="Verdana" Size="2">How long has employee worked at job where
injury
occurred?<br><asp:textbox id="lengthofjob" runat=server/>

</td>

<%--__________________________________________________ __________________________--%>

<%--Row 4--%>

&nbsp&nbsp

<p>
<asp:Label id=Label1 font-name="arial" font-size="10pt"
runat="server"/>

<!Copied from /smirnof>

<asp:panel id="panelSendEmail" runat="server">

<%--asp:textbox id= runat="server" /--%>

<br>

<b>Your Message:</b><br>

<%--asp:textbox id="txtMessage" TextMode="MultiLine"

Columns="40" Rows="10" runat="server" /--%>

<p>

<asp:button runat="server" id="btnSendFeedback" Text="Send

Feedback!"

OnClick="btnSendFeedback_Click" />

</asp:panel>

<asp:panel id="panelMailSent" runat="server" Visible="False">

An email has been sent to the email address you specified.

Thanks!

</asp:panel>

</form>

</body>

</html>





May 10 '07 #10

P: n/a
Ah,

Sorry, I have my newsreader on to ignore read messages.

The P tags break the lines in the rendered page. BR tags also break lines
(work as a hard wrap).

vbCrLf is a Visual Basic Carriage Return Line Feed. All this does is allow
the source html wrap onto a new line, so that your line is not too long.

If you want to use the same thing in C#, then it is something like...

email.Body = "This is my email body\nNow I am on a new line\nNote the
backslash and n to create a new line\n. I can't remember though, you might
need \r\n to create a new line";

backslash n.

Is that what you looking for? This however doesn't affect your rendered
output. use \n where there is vbcrlf, however, vbcrlf is a defined constant,
and \n has to be in quotes.

What you could do though is...

string vbCrLf = "\n";

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"dancer" <da****@microsoft.comwrote in message
news:u3**************@TK2MSFTNGP04.phx.gbl...
David,

Not exactly does this answer my question. Could you please check out
Juan's answer to my first post on this subject and help me understand,
since I was copying my code from this code.

Thank you.
"David" <da*****************@revilloc.REMOVETHIS.comwrot e in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>The vbCrLf are purely to ensure that the line is not too long when
generated. There is a problem with over long lines that when they do
eventually wrap, it can disrupt your formatted email.

You will note that there are no br tags, but there are p tags <pand
</p>. These are what cause <P>aragraph breaks. (Actually, they are for
new paragraphs rather than breaking paragraphs).

Does this answer your question?

(Note, you probably can't press "Yes" below as you probably can't see it.
If you can, then you have better eyes than me, as I can't see it. :-)

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available

"dancer" <da****@microsoft.comwrote in message
news:uH**************@TK2MSFTNGP04.phx.gbl...
>>Hi Juan,

What is the difference in what I am trying to do and this? Why can THEY
break up the HTML content into different lines?

email_html.aspx
--------------------------------------------------------------------------------

<%@ Page Language="VB" ClientTarget="downlevel" %>
<%@ Import Namespace="System.Web.Mail" %>
<script language="VB" runat="server">
Sub btnSendMail_OnClick(Source As Object, E As EventArgs)
Dim myMessage As New MailMessage
Dim myMail As SmtpMail
Dim strEmail As String

If Page.IsValid() Then
strEmail = txtEmail.Text

'myMessage.From = "webmaster@" &
Request.ServerVariables("SERVER_NAME")
myMessage.From = "we*******@asp101.com"
myMessage.To = strEmail
myMessage.Subject = "E-mail Sample (HTML) from ASP 101!"

' This is the magic line. Without this the message will just appear
' as plain HTML and won't be rendered by the recipient's email client.
' It'd be as if they did "View Source" on a web page.
MyMessage.BodyFormat = MailFormat.Html

' This is multi-lined simply for readability.
' Notice that it is a properly formatted HTML
' message and not just plain text like most email.
' A lot of people have asked how to use form data
' in the emails so I added an example of including
' the entered address in the body of the email.
myMessage.Body = "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0
Transitional//EN"">" & vbCrLf _
& "<html>" & vbCrLf _
& "<head>" & vbCrLf _
& " <title>Sample Message From ASP 101</title>" & vbCrLf _
& " <meta http-equiv=Content-Type content=""text/html;
charset=iso-8859-1"">" & vbCrLf _
& "</head>" & vbCrLf _
& "<body bgcolor=""#FFFFCC"">" & vbCrLf _
& " <h2>Sample Message From ASP 101</h2>" & vbCrLf _
& " <p>" & vbCrLf _
& " This message was sent from a sample at" & vbCrLf _
& " <a href=""http://www.asp101.com"">ASP 101</a>." & vbCrLf _
& " It is used to show people how to send HTML" & vbCrLf _
& " formatted email from an ASP.NET page." & vbCrLf _
& " If you did not request this email yourself," & vbCrLf _
& " your address was entered by one of our" & vbCrLf _
& " visitors." & vbCrLf _
& " <strong>" & vbCrLf _
& " We do not store these e-mail addresses." & vbCrLf _
& " </strong>" & vbCrLf _
& " </p>" & vbCrLf _
& " <p><font size=""-1"">Please address all concerns to
we*******@asp101.com.</font></p>" & vbCrLf _
& " <p><font size=""-1"">This message was sent to: " & strEmail &
"</font></p>" & vbCrLf _
& "</body>" & vbCrLf _
& "</html>" & vbCrLf

' Doesn't have to be local... just enter your
' SMTP server's name or ip address!
myMail.SmtpServer = "localhost"
myMail.Send(myMessage)

frmEmail.Visible = False
lblUserMessage.Text = "An HTML-formatted email message has been sent to
" & strEmail & "."
End If
End Sub
</script>

<html>
<head>
<title>ASP.NET Email (HTML Format) Sample</title>
</head>
<body>

<asp:Label id="lblUserMessage" text="Enter your e-mail address:"
runat="server" />
<form method="post" id="frmEmail" runat="server">
<asp:TextBox id="txtEmail" size="30" runat="server" />
<asp:RequiredFieldValidator runat="server"
id="validEmailRequired" ControlToValidate="txtEmail"
errormessage="Please enter an email address."
display="Dynamic" />
<asp:RegularExpressionValidator runat="server"
id="validEmailRegExp" ControlToValidate="txtEmail"
ValidationExpression="^[\w-]+@[\w-]+\.(com|net|org|edu|mil)$"
errormessage="Please enter a valid email address."
Display="Dynamic" />

<asp:Button id="btnSendMail" text="Send Mail!"
OnClick="btnSendMail_OnClick" runat="server" />
</form>

<hr />

<p>
Click <a
href="http://www.asp101.com/samples/email_html_aspx.asp">here</ato
read about and download the source code.
</p>

</body>
</html>
--------------------------------------------------------------------------------

"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl.. .
You don't need to set the html/head/body tags within the HTML body
...and, in the VbCrLf thread, we established that you can't use VbCrLf
in HTML.

Something else : you *must* put all the HTML content in ONE line.
You can't break the lines with code.

Get rid of all the "VbCrLf" and all the "&" and write all your HTML in
a single line,
line-breaking the body's content with "<br />" or "<P... </P>" as
needed.

Also, you can't insert Textbox controls into your HTML.

So, Check1.Text is out, too.

If you want to reference their content, after a user fills them out,
capture it to a variable and use that, before writing to the body.

insert :

Dim Check1 as String = Check1.Text
Dim Check2 as String = Check2.Text
Dim Location as String = Location.Text
before "Dim objMM as New MailMessage()"

and, when composing the body, use :

mail.Body="Hi, <p>The location where the accident occurred is :" &
Location & "<br/>" & Check1 & "."
' etc.

You *can* use the & to reference text variables.
Notice the location of the quote marks.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"dancer" <da****@microsoft.comwrote in message
news:uU*************@TK2MSFTNGP05.phx.gbl...
Can somebody tell me why I get this message with the following code?
>
Compiler Error Message: BC30452: Operator '&' is not defined for types
'String' and
'System.Web.UI.WebControls.TextBox'.
>
<html>
>
<head>
>
<% @Import Namespace="System.Web.Mail" %>
>
<script language="VB" runat="server">
>
>
>
Sub btnSendFeedback_Click(sender as Object, e as EventArgs)
>
'Create an instance of the MailMessage class
>
Dim objMM as New MailMessage()
>
'Set the properties - send the email to the person who filled out the
>
'feedback form.
>
objMM.To = "xx*****@xxxxxxx.com"
>
>
objMM.From = "xx*****@xxxxxxx.com"
>
'send in html format
>
objMM.BodyFormat = MailFormat.html
>
'Set the priority - options are High, Low, and Normal
>
objMM.Priority = MailPriority.Normal
>
'Set the subject
>
objMM.Subject = "Accident Investigation Form"
>
>
'Set the body
>
objMM.Body = DateTime.Now + " HI " & _
>
"<html>" & vbCrLf & vbCrLf & _
>
"<head>" & vbCrLf & vbCrLf & _
>
"</head>"& vbCrLf & vbCrLf & _
>
"<body>" & vbCrLf & vbCrLf & _
>
Location where accident occurred:
>
Location.Text & _
>
"<br>"& _
>
7Check1.Text & "." & vbCrLf & vbCrLf & _
>
vbCrLf &vbCrLf & _
>
Check2.Text & vbCrLf & _
>
"</td>" & vbCrLf & vbCrLf & _
>
"</body>" & vbCrLf & vbCrLf & _
>
"</html>"
>
>
'Specify to use the default Smtp Server
>
SmtpMail.SmtpServer = ""
>
'Now, to send the message, use the Send method of the SmtpMail class
>
SmtpMail.Send(objMM)
>
panelSendEmail.Visible = false
>
panelMailSent.Visible = true
>
End Sub
>
>
>
</script>
>
</head>
>
>
<body>
>
<table width="750" bgcolor="#E9EDF4" table border="1" cellpadding="3">
>
<h3><center><font face="Verdana">Wheeler's Accident Investigation
Form</font></h3>
>
>
>
<hr>
>
<%--__________________________________________________ __________________________--%>
>
<%--ROW 1--%>
>
>
<td width="250" valign="top">
>
>
<form runat="server">
>
<font face="Verdana" Size="2">
>
Location where accident occurred: <asp:textbox id="Location"
runat=server Width="200"/>
>
</td>
>
<td align="right" valign="top" width="225">
>
>
<font face="Verdana" Size="2">Employer's Premises
>
>
>
<asp:CheckBox id=Check1 Text="yes" runat="server" />
>
<asp:CheckBox id=Check2 Text="no" runat="server" />
>
<br>
>
>
Job site
>
<asp:CheckBox id=Check3 Text="yes" runat="server" />
>
<asp:CheckBox id=Check4 Text="no" runat="server" />
>
>
</td>
>
<td>
>
<font face="Verdana" Size="2">Date of accident</font><br>
>
<asp:textbox id="Date" runat=server Width="100"/>
>
>
</td>
>
<%--__________________________________________________ __________________________--%>
>
<%--ROW 2--%>
>
>
<tr<td>
>
<font face="Verdana" Size="2">Who was injured?</font><br>
>
<asp:textbox id="Who" runat=server width="200"/>
>
</td>
>
<td align= "left">
>
<font face="Verdana" Size="2">Employee <asp:CheckBox id=Check5
runat="server" />
>
<br>
>
Non-employee <asp:CheckBox id=Check6 runat="server" />
>
>
</td>
>
<td align="right"><font face="Verdana" Size="2">
>
Time of accident a.m. <asp:textbox id="am" runat=server Width="90"/>
>
p.m. <asp:textbox id="pm" runat=server Width="90"/>
>
</TD>
>
<%--__________________________________________________ __________________________--%>
>
<%--ROW 3--%>
>
<tr>
>
<td>
>
<font face="Verdana" Size="2">Date of Hire <br<asp:textbox
id="Hiredate" runat=server/>
>
</td>
>
<td>
>
<font face="Verdana" Size="2">Job Title or Occupation <br><asp:textbox
id="occupation"
runat=server width="200"/>
>
</td>
>
<td>
>
<font face="Verdana" Size="2">How long has employee worked at job
where injury
occurred?<br><asp:textbox id="lengthofjob" runat=server/>
>
</td>
>
<%--__________________________________________________ __________________________--%>
>
<%--Row 4--%>
>
&nbsp&nbsp
>
>
>
<p>
>
>
<asp:Label id=Label1 font-name="arial" font-size="10pt"
runat="server"/>
>
<!Copied from /smirnof>
>
<asp:panel id="panelSendEmail" runat="server">
>
>
>
>
>
<%--asp:textbox id= runat="server" /--%>
>
<br>
>
<b>Your Message:</b><br>
>
<%--asp:textbox id="txtMessage" TextMode="MultiLine"
>
Columns="40" Rows="10" runat="server" /--%>
>
<p>
>
>
>
<asp:button runat="server" id="btnSendFeedback" Text="Send
>
Feedback!"
>
OnClick="btnSendFeedback_Click" />
>
>
>
</asp:panel>
>
<asp:panel id="panelMailSent" runat="server" Visible="False">
>
An email has been sent to the email address you specified.
>
Thanks!
>
</asp:panel>
>
</form>
>
</body>
>
</html>
>
>





May 10 '07 #11

P: n/a
You have the br run right up against an ampersand, which could be your
issue.

My question is why you are building the page like an ASP page instead of an
ASP.NET page? In other words, why build when you can bind?

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com

*********************************************
Think outside the box!
*********************************************
"dancer" <da****@microsoft.comwrote in message
news:uU*************@TK2MSFTNGP05.phx.gbl...
Can somebody tell me why I get this message with the following code?

Compiler Error Message: BC30452: Operator '&' is not defined for types
'String' and 'System.Web.UI.WebControls.TextBox'.

<html>

<head>

<% @Import Namespace="System.Web.Mail" %>

<script language="VB" runat="server">

Sub btnSendFeedback_Click(sender as Object, e as EventArgs)

'Create an instance of the MailMessage class

Dim objMM as New MailMessage()

'Set the properties - send the email to the person who filled out the

'feedback form.

objMM.To = "xx*****@xxxxxxx.com"
objMM.From = "xx*****@xxxxxxx.com"

'send in html format

objMM.BodyFormat = MailFormat.html

'Set the priority - options are High, Low, and Normal

objMM.Priority = MailPriority.Normal

'Set the subject

objMM.Subject = "Accident Investigation Form"
'Set the body

objMM.Body = DateTime.Now + " HI " & _

"<html>" & vbCrLf & vbCrLf & _

"<head>" & vbCrLf & vbCrLf & _

"</head>"& vbCrLf & vbCrLf & _

"<body>" & vbCrLf & vbCrLf & _

Location where accident occurred:

Location.Text & _

"<br>"& _

Check1.Text & "." & vbCrLf & vbCrLf & _

vbCrLf &vbCrLf & _

Check2.Text & vbCrLf & _

"</td>" & vbCrLf & vbCrLf & _

"</body>" & vbCrLf & vbCrLf & _

"</html>"
'Specify to use the default Smtp Server

SmtpMail.SmtpServer = ""

'Now, to send the message, use the Send method of the SmtpMail class

SmtpMail.Send(objMM)

panelSendEmail.Visible = false

panelMailSent.Visible = true

End Sub

</script>

</head>
<body>

<table width="750" bgcolor="#E9EDF4" table border="1" cellpadding="3">

<h3><center><font face="Verdana">Wheeler's Accident Investigation
Form</font></h3>

<hr>

<%--__________________________________________________ __________________________--%>

<%--ROW 1--%>
<td width="250" valign="top">
<form runat="server">

<font face="Verdana" Size="2">

Location where accident occurred: <asp:textbox id="Location" runat=server
Width="200"/>

</td>

<td align="right" valign="top" width="225">
<font face="Verdana" Size="2">Employer's Premises

<asp:CheckBox id=Check1 Text="yes" runat="server" />

<asp:CheckBox id=Check2 Text="no" runat="server" />

<br>
Job site

<asp:CheckBox id=Check3 Text="yes" runat="server" />

<asp:CheckBox id=Check4 Text="no" runat="server" />
</td>

<td>

<font face="Verdana" Size="2">Date of accident</font><br>

<asp:textbox id="Date" runat=server Width="100"/>
</td>

<%--__________________________________________________ __________________________--%>

<%--ROW 2--%>
<tr<td>

<font face="Verdana" Size="2">Who was injured?</font><br>

<asp:textbox id="Who" runat=server width="200"/>

</td>

<td align= "left">

<font face="Verdana" Size="2">Employee <asp:CheckBox id=Check5
runat="server" />

<br>

Non-employee <asp:CheckBox id=Check6 runat="server" />
</td>

<td align="right"><font face="Verdana" Size="2">

Time of accident a.m. <asp:textbox id="am" runat=server Width="90"/>

p.m. <asp:textbox id="pm" runat=server Width="90"/>

</TD>

<%--__________________________________________________ __________________________--%>

<%--ROW 3--%>

<tr>

<td>

<font face="Verdana" Size="2">Date of Hire <br<asp:textbox id="Hiredate"
runat=server/>

</td>

<td>

<font face="Verdana" Size="2">Job Title or Occupation <br><asp:textbox
id="occupation" runat=server width="200"/>

</td>

<td>

<font face="Verdana" Size="2">How long has employee worked at job where
injury occurred?<br><asp:textbox id="lengthofjob" runat=server/>

</td>

<%--__________________________________________________ __________________________--%>

<%--Row 4--%>

&nbsp&nbsp

<p>
<asp:Label id=Label1 font-name="arial" font-size="10pt" runat="server"/>

<!Copied from /smirnof>

<asp:panel id="panelSendEmail" runat="server">

<%--asp:textbox id= runat="server" /--%>

<br>

<b>Your Message:</b><br>

<%--asp:textbox id="txtMessage" TextMode="MultiLine"

Columns="40" Rows="10" runat="server" /--%>

<p>

<asp:button runat="server" id="btnSendFeedback" Text="Send

Feedback!"

OnClick="btnSendFeedback_Click" />

</asp:panel>

<asp:panel id="panelMailSent" runat="server" Visible="False">

An email has been sent to the email address you specified.

Thanks!

</asp:panel>

</form>

</body>

</html>

May 10 '07 #12

P: n/a
I understand what is <brand what is & vbCrLf

But Juan said "You *must* put all the HTML content in ONE line. You can't
break the lines with code."
????

Thanks

"David" <da*****************@revilloc.REMOVETHIS.comwrot e in message
news:ux**************@TK2MSFTNGP03.phx.gbl...
Ah,

Sorry, I have my newsreader on to ignore read messages.

The P tags break the lines in the rendered page. BR tags also break lines
(work as a hard wrap).

vbCrLf is a Visual Basic Carriage Return Line Feed. All this does is allow
the source html wrap onto a new line, so that your line is not too long.

If you want to use the same thing in C#, then it is something like...

email.Body = "This is my email body\nNow I am on a new line\nNote the
backslash and n to create a new line\n. I can't remember though, you might
need \r\n to create a new line";

backslash n.

Is that what you looking for? This however doesn't affect your rendered
output. use \n where there is vbcrlf, however, vbcrlf is a defined
constant, and \n has to be in quotes.

What you could do though is...

string vbCrLf = "\n";

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"dancer" <da****@microsoft.comwrote in message
news:u3**************@TK2MSFTNGP04.phx.gbl...
>David,

Not exactly does this answer my question. Could you please check out
Juan's answer to my first post on this subject and help me understand,
since I was copying my code from this code.

Thank you.
"David" <da*****************@revilloc.REMOVETHIS.comwrot e in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>>The vbCrLf are purely to ensure that the line is not too long when
generated. There is a problem with over long lines that when they do
eventually wrap, it can disrupt your formatted email.

You will note that there are no br tags, but there are p tags <pand
</p>. These are what cause <P>aragraph breaks. (Actually, they are for
new paragraphs rather than breaking paragraphs).

Does this answer your question?

(Note, you probably can't press "Yes" below as you probably can't see
it. If you can, then you have better eyes than me, as I can't see it.
:-)

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available

"dancer" <da****@microsoft.comwrote in message
news:uH**************@TK2MSFTNGP04.phx.gbl...
Hi Juan,

What is the difference in what I am trying to do and this? Why can
THEY break up the HTML content into different lines?

email_html.aspx
--------------------------------------------------------------------------------

<%@ Page Language="VB" ClientTarget="downlevel" %>
<%@ Import Namespace="System.Web.Mail" %>
<script language="VB" runat="server">
Sub btnSendMail_OnClick(Source As Object, E As EventArgs)
Dim myMessage As New MailMessage
Dim myMail As SmtpMail
Dim strEmail As String

If Page.IsValid() Then
strEmail = txtEmail.Text

'myMessage.From = "webmaster@" &
Request.ServerVariables("SERVER_NAME")
myMessage.From = "we*******@asp101.com"
myMessage.To = strEmail
myMessage.Subject = "E-mail Sample (HTML) from ASP 101!"

' This is the magic line. Without this the message will just appear
' as plain HTML and won't be rendered by the recipient's email client.
' It'd be as if they did "View Source" on a web page.
MyMessage.BodyFormat = MailFormat.Html

' This is multi-lined simply for readability.
' Notice that it is a properly formatted HTML
' message and not just plain text like most email.
' A lot of people have asked how to use form data
' in the emails so I added an example of including
' the entered address in the body of the email.
myMessage.Body = "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0
Transitional//EN"">" & vbCrLf _
& "<html>" & vbCrLf _
& "<head>" & vbCrLf _
& " <title>Sample Message From ASP 101</title>" & vbCrLf _
& " <meta http-equiv=Content-Type content=""text/html;
charset=iso-8859-1"">" & vbCrLf _
& "</head>" & vbCrLf _
& "<body bgcolor=""#FFFFCC"">" & vbCrLf _
& " <h2>Sample Message From ASP 101</h2>" & vbCrLf _
& " <p>" & vbCrLf _
& " This message was sent from a sample at" & vbCrLf _
& " <a href=""http://www.asp101.com"">ASP 101</a>." & vbCrLf _
& " It is used to show people how to send HTML" & vbCrLf _
& " formatted email from an ASP.NET page." & vbCrLf _
& " If you did not request this email yourself," & vbCrLf _
& " your address was entered by one of our" & vbCrLf _
& " visitors." & vbCrLf _
& " <strong>" & vbCrLf _
& " We do not store these e-mail addresses." & vbCrLf _
& " </strong>" & vbCrLf _
& " </p>" & vbCrLf _
& " <p><font size=""-1"">Please address all concerns to
we*******@asp101.com.</font></p>" & vbCrLf _
& " <p><font size=""-1"">This message was sent to: " & strEmail &
"</font></p>" & vbCrLf _
& "</body>" & vbCrLf _
& "</html>" & vbCrLf

' Doesn't have to be local... just enter your
' SMTP server's name or ip address!
myMail.SmtpServer = "localhost"
myMail.Send(myMessage)

frmEmail.Visible = False
lblUserMessage.Text = "An HTML-formatted email message has been sent to
" & strEmail & "."
End If
End Sub
</script>

<html>
<head>
<title>ASP.NET Email (HTML Format) Sample</title>
</head>
<body>

<asp:Label id="lblUserMessage" text="Enter your e-mail address:"
runat="server" />
<form method="post" id="frmEmail" runat="server">
<asp:TextBox id="txtEmail" size="30" runat="server" />
<asp:RequiredFieldValidator runat="server"
id="validEmailRequired" ControlToValidate="txtEmail"
errormessage="Please enter an email address."
display="Dynamic" />
<asp:RegularExpressionValidator runat="server"
id="validEmailRegExp" ControlToValidate="txtEmail"
ValidationExpression="^[\w-]+@[\w-]+\.(com|net|org|edu|mil)$"
errormessage="Please enter a valid email address."
Display="Dynamic" />

<asp:Button id="btnSendMail" text="Send Mail!"
OnClick="btnSendMail_OnClick" runat="server" />
</form>

<hr />

<p>
Click <a
href="http://www.asp101.com/samples/email_html_aspx.asp">here</ato
read about and download the source code.
</p>

</body>
</html>
--------------------------------------------------------------------------------

"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl. ..
You don't need to set the html/head/body tags within the HTML body
...and, in the VbCrLf thread, we established that you can't use VbCrLf
in HTML.
>
Something else : you *must* put all the HTML content in ONE line.
You can't break the lines with code.
>
Get rid of all the "VbCrLf" and all the "&" and write all your HTML in
a single line,
line-breaking the body's content with "<br />" or "<P... </P>" as
needed.
>
Also, you can't insert Textbox controls into your HTML.
>
So, Check1.Text is out, too.
>
If you want to reference their content, after a user fills them out,
capture it to a variable and use that, before writing to the body.
>
insert :
>
Dim Check1 as String = Check1.Text
Dim Check2 as String = Check2.Text
Dim Location as String = Location.Text
before "Dim objMM as New MailMessage()"
>
and, when composing the body, use :
>
mail.Body="Hi, <p>The location where the accident occurred is :" &
Location & "<br/>" & Check1 & "."
' etc.
>
You *can* use the & to reference text variables.
Notice the location of the quote marks.
>
>
>
>
>
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"dancer" <da****@microsoft.comwrote in message
news:uU*************@TK2MSFTNGP05.phx.gbl...
>Can somebody tell me why I get this message with the following code?
>>
>Compiler Error Message: BC30452: Operator '&' is not defined for
>types 'String' and
>'System.Web.UI.WebControls.TextBox'.
>>
><html>
>>
><head>
>>
><% @Import Namespace="System.Web.Mail" %>
>>
><script language="VB" runat="server">
>>
>>
>>
>Sub btnSendFeedback_Click(sender as Object, e as EventArgs)
>>
>'Create an instance of the MailMessage class
>>
>Dim objMM as New MailMessage()
>>
>'Set the properties - send the email to the person who filled out the
>>
>'feedback form.
>>
>objMM.To = "xx*****@xxxxxxx.com"
>>
>>
>objMM.From = "xx*****@xxxxxxx.com"
>>
>'send in html format
>>
>objMM.BodyFormat = MailFormat.html
>>
>'Set the priority - options are High, Low, and Normal
>>
>objMM.Priority = MailPriority.Normal
>>
>'Set the subject
>>
>objMM.Subject = "Accident Investigation Form"
>>
>>
>'Set the body
>>
>objMM.Body = DateTime.Now + " HI " & _
>>
>"<html>" & vbCrLf & vbCrLf & _
>>
>"<head>" & vbCrLf & vbCrLf & _
>>
>"</head>"& vbCrLf & vbCrLf & _
>>
>"<body>" & vbCrLf & vbCrLf & _
>>
>Location where accident occurred:
>>
>Location.Text & _
>>
>"<br>"& _
>>
7Check1.Text & "." & vbCrLf & vbCrLf & _
>>
>vbCrLf &vbCrLf & _
>>
>Check2.Text & vbCrLf & _
>>
>"</td>" & vbCrLf & vbCrLf & _
>>
>"</body>" & vbCrLf & vbCrLf & _
>>
>"</html>"
>>
>>
>'Specify to use the default Smtp Server
>>
>SmtpMail.SmtpServer = ""
>>
>'Now, to send the message, use the Send method of the SmtpMail class
>>
>SmtpMail.Send(objMM)
>>
>panelSendEmail.Visible = false
>>
>panelMailSent.Visible = true
>>
>End Sub
>>
>>
>>
></script>
>>
></head>
>>
>>
><body>
>>
><table width="750" bgcolor="#E9EDF4" table border="1"
>cellpadding="3">
>>
><h3><center><font face="Verdana">Wheeler's Accident Investigation
>Form</font></h3>
>>
>>
>>
><hr>
>>
><%--__________________________________________________ __________________________--%>
>>
><%--ROW 1--%>
>>
>>
><td width="250" valign="top">
>>
>>
><form runat="server">
>>
><font face="Verdana" Size="2">
>>
>Location where accident occurred: <asp:textbox id="Location"
>runat=server Width="200"/>
>>
></td>
>>
><td align="right" valign="top" width="225">
>>
>>
><font face="Verdana" Size="2">Employer's Premises
>>
>>
>>
><asp:CheckBox id=Check1 Text="yes" runat="server" />
>>
><asp:CheckBox id=Check2 Text="no" runat="server" />
>>
><br>
>>
>>
>Job site
>>
><asp:CheckBox id=Check3 Text="yes" runat="server" />
>>
><asp:CheckBox id=Check4 Text="no" runat="server" />
>>
>>
></td>
>>
><td>
>>
><font face="Verdana" Size="2">Date of accident</font><br>
>>
><asp:textbox id="Date" runat=server Width="100"/>
>>
>>
></td>
>>
><%--__________________________________________________ __________________________--%>
>>
><%--ROW 2--%>
>>
>>
><tr<td>
>>
><font face="Verdana" Size="2">Who was injured?</font><br>
>>
><asp:textbox id="Who" runat=server width="200"/>
>>
></td>
>>
><td align= "left">
>>
><font face="Verdana" Size="2">Employee <asp:CheckBox id=Check5
>runat="server" />
>>
><br>
>>
>Non-employee <asp:CheckBox id=Check6 runat="server" />
>>
>>
></td>
>>
><td align="right"><font face="Verdana" Size="2">
>>
>Time of accident a.m. <asp:textbox id="am" runat=server Width="90"/>
>>
>p.m. <asp:textbox id="pm" runat=server Width="90"/>
>>
></TD>
>>
><%--__________________________________________________ __________________________--%>
>>
><%--ROW 3--%>
>>
><tr>
>>
><td>
>>
><font face="Verdana" Size="2">Date of Hire <br<asp:textbox
>id="Hiredate" runat=server/>
>>
></td>
>>
><td>
>>
><font face="Verdana" Size="2">Job Title or Occupation
><br><asp:textbox id="occupation"
>runat=server width="200"/>
>>
></td>
>>
><td>
>>
><font face="Verdana" Size="2">How long has employee worked at job
>where injury
>occurred?<br><asp:textbox id="lengthofjob" runat=server/>
>>
></td>
>>
><%--__________________________________________________ __________________________--%>
>>
><%--Row 4--%>
>>
>&nbsp&nbsp
>>
>>
>>
><p>
>>
>>
><asp:Label id=Label1 font-name="arial" font-size="10pt"
>runat="server"/>
>>
><!Copied from /smirnof>
>>
><asp:panel id="panelSendEmail" runat="server">
>>
>>
>>
>>
>>
><%--asp:textbox id= runat="server" /--%>
>>
><br>
>>
><b>Your Message:</b><br>
>>
><%--asp:textbox id="txtMessage" TextMode="MultiLine"
>>
>Columns="40" Rows="10" runat="server" /--%>
>>
><p>
>>
>>
>>
><asp:button runat="server" id="btnSendFeedback" Text="Send
>>
>Feedback!"
>>
>OnClick="btnSendFeedback_Click" />
>>
>>
>>
></asp:panel>
>>
><asp:panel id="panelMailSent" runat="server" Visible="False">
>>
>An email has been sent to the email address you specified.
>>
>Thanks!
>>
></asp:panel>
>>
></form>
>>
></body>
>>
></html>
>>
>>
>
>





May 10 '07 #13

P: n/a
Right...

What you can do though is...

string MailBody = string.empty;

MailBody += "<p>First Line\n";
MailBody += "Second Line\n";
MailBody += "Third Line</p>\n"; // Note, all these will appear on same
line in message, but on seperate lines in the source.

email.Body = MailBody;

I think you are getting a little confused.

I have used string here. StringBuilder would actually be more efficient if
doing many lines like this.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"dancer" <da****@microsoft.comwrote in message
news:OI**************@TK2MSFTNGP03.phx.gbl...
>I understand what is <brand what is & vbCrLf

But Juan said "You *must* put all the HTML content in ONE line. You can't
break the lines with code."
????

Thanks

"David" <da*****************@revilloc.REMOVETHIS.comwrot e in message
news:ux**************@TK2MSFTNGP03.phx.gbl...
>Ah,

Sorry, I have my newsreader on to ignore read messages.

The P tags break the lines in the rendered page. BR tags also break lines
(work as a hard wrap).

vbCrLf is a Visual Basic Carriage Return Line Feed. All this does is
allow the source html wrap onto a new line, so that your line is not too
long.

If you want to use the same thing in C#, then it is something like...

email.Body = "This is my email body\nNow I am on a new line\nNote the
backslash and n to create a new line\n. I can't remember though, you
might need \r\n to create a new line";

backslash n.

Is that what you looking for? This however doesn't affect your rendered
output. use \n where there is vbcrlf, however, vbcrlf is a defined
constant, and \n has to be in quotes.

What you could do though is...

string vbCrLf = "\n";

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"dancer" <da****@microsoft.comwrote in message
news:u3**************@TK2MSFTNGP04.phx.gbl...
>>David,

Not exactly does this answer my question. Could you please check out
Juan's answer to my first post on this subject and help me understand,
since I was copying my code from this code.

Thank you.
"David" <da*****************@revilloc.REMOVETHIS.comwrot e in message
news:%2****************@TK2MSFTNGP02.phx.gbl.. .
The vbCrLf are purely to ensure that the line is not too long when
generated. There is a problem with over long lines that when they do
eventually wrap, it can disrupt your formatted email.

You will note that there are no br tags, but there are p tags <pand
</p>. These are what cause <P>aragraph breaks. (Actually, they are for
new paragraphs rather than breaking paragraphs).

Does this answer your question?

(Note, you probably can't press "Yes" below as you probably can't see
it. If you can, then you have better eyes than me, as I can't see it.
:-)

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available

"dancer" <da****@microsoft.comwrote in message
news:uH**************@TK2MSFTNGP04.phx.gbl...
Hi Juan,
>
What is the difference in what I am trying to do and this? Why can
THEY break up the HTML content into different lines?
>
email_html.aspx
--------------------------------------------------------------------------------
>
<%@ Page Language="VB" ClientTarget="downlevel" %>
<%@ Import Namespace="System.Web.Mail" %>
<script language="VB" runat="server">
Sub btnSendMail_OnClick(Source As Object, E As EventArgs)
Dim myMessage As New MailMessage
Dim myMail As SmtpMail
Dim strEmail As String
>
If Page.IsValid() Then
strEmail = txtEmail.Text
>
'myMessage.From = "webmaster@" &
Request.ServerVariables("SERVER_NAME")
myMessage.From = "we*******@asp101.com"
myMessage.To = strEmail
myMessage.Subject = "E-mail Sample (HTML) from ASP 101!"
>
' This is the magic line. Without this the message will just appear
' as plain HTML and won't be rendered by the recipient's email client.
' It'd be as if they did "View Source" on a web page.
MyMessage.BodyFormat = MailFormat.Html
>
' This is multi-lined simply for readability.
' Notice that it is a properly formatted HTML
' message and not just plain text like most email.
' A lot of people have asked how to use form data
' in the emails so I added an example of including
' the entered address in the body of the email.
myMessage.Body = "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0
Transitional//EN"">" & vbCrLf _
& "<html>" & vbCrLf _
& "<head>" & vbCrLf _
& " <title>Sample Message From ASP 101</title>" & vbCrLf _
& " <meta http-equiv=Content-Type content=""text/html;
charset=iso-8859-1"">" & vbCrLf _
& "</head>" & vbCrLf _
& "<body bgcolor=""#FFFFCC"">" & vbCrLf _
& " <h2>Sample Message From ASP 101</h2>" & vbCrLf _
& " <p>" & vbCrLf _
& " This message was sent from a sample at" & vbCrLf _
& " <a href=""http://www.asp101.com"">ASP 101</a>." & vbCrLf _
& " It is used to show people how to send HTML" & vbCrLf _
& " formatted email from an ASP.NET page." & vbCrLf _
& " If you did not request this email yourself," & vbCrLf _
& " your address was entered by one of our" & vbCrLf _
& " visitors." & vbCrLf _
& " <strong>" & vbCrLf _
& " We do not store these e-mail addresses." & vbCrLf _
& " </strong>" & vbCrLf _
& " </p>" & vbCrLf _
& " <p><font size=""-1"">Please address all concerns to
we*******@asp101.com.</font></p>" & vbCrLf _
& " <p><font size=""-1"">This message was sent to: " & strEmail &
"</font></p>" & vbCrLf _
& "</body>" & vbCrLf _
& "</html>" & vbCrLf
>
' Doesn't have to be local... just enter your
' SMTP server's name or ip address!
myMail.SmtpServer = "localhost"
myMail.Send(myMessage)
>
frmEmail.Visible = False
lblUserMessage.Text = "An HTML-formatted email message has been sent
to " & strEmail & "."
End If
End Sub
</script>
>
<html>
<head>
<title>ASP.NET Email (HTML Format) Sample</title>
</head>
<body>
>
<asp:Label id="lblUserMessage" text="Enter your e-mail address:"
runat="server" />
<form method="post" id="frmEmail" runat="server">
<asp:TextBox id="txtEmail" size="30" runat="server" />
<asp:RequiredFieldValidator runat="server"
id="validEmailRequired" ControlToValidate="txtEmail"
errormessage="Please enter an email address."
display="Dynamic" />
<asp:RegularExpressionValidator runat="server"
id="validEmailRegExp" ControlToValidate="txtEmail"
ValidationExpression="^[\w-]+@[\w-]+\.(com|net|org|edu|mil)$"
errormessage="Please enter a valid email address."
Display="Dynamic" />
>
<asp:Button id="btnSendMail" text="Send Mail!"
OnClick="btnSendMail_OnClick" runat="server" />
</form>
>
<hr />
>
<p>
Click <a
href="http://www.asp101.com/samples/email_html_aspx.asp">here</ato
read about and download the source code.
</p>
>
</body>
</html>
>
>
--------------------------------------------------------------------------------
>
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl.. .
>You don't need to set the html/head/body tags within the HTML body
>...and, in the VbCrLf thread, we established that you can't use
>VbCrLf in HTML.
>>
>Something else : you *must* put all the HTML content in ONE line.
>You can't break the lines with code.
>>
>Get rid of all the "VbCrLf" and all the "&" and write all your HTML
>in a single line,
>line-breaking the body's content with "<br />" or "<P... </P>" as
>needed.
>>
>Also, you can't insert Textbox controls into your HTML.
>>
>So, Check1.Text is out, too.
>>
>If you want to reference their content, after a user fills them out,
>capture it to a variable and use that, before writing to the body.
>>
>insert :
>>
>Dim Check1 as String = Check1.Text
>Dim Check2 as String = Check2.Text
>Dim Location as String = Location.Text
>before "Dim objMM as New MailMessage()"
>>
>and, when composing the body, use :
>>
>mail.Body="Hi, <p>The location where the accident occurred is :" &
>Location & "<br/>" & Check1 & "."
>' etc.
>>
>You *can* use the & to reference text variables.
>Notice the location of the quote marks.
>>
>>
>>
>>
>>
>Juan T. Llibre, asp.net MVP
>asp.net faq : http://asp.net.do/faq/
>foros de asp.net, en español : http://asp.net.do/foros/
>===================================
>"dancer" <da****@microsoft.comwrote in message
>news:uU*************@TK2MSFTNGP05.phx.gbl.. .
>>Can somebody tell me why I get this message with the following code?
>>>
>>Compiler Error Message: BC30452: Operator '&' is not defined for
>>types 'String' and
>>'System.Web.UI.WebControls.TextBox'.
>>>
>><html>
>>>
>><head>
>>>
>><% @Import Namespace="System.Web.Mail" %>
>>>
>><script language="VB" runat="server">
>>>
>>>
>>>
>>Sub btnSendFeedback_Click(sender as Object, e as EventArgs)
>>>
>>'Create an instance of the MailMessage class
>>>
>>Dim objMM as New MailMessage()
>>>
>>'Set the properties - send the email to the person who filled out
>>the
>>>
>>'feedback form.
>>>
>>objMM.To = "xx*****@xxxxxxx.com"
>>>
>>>
>>objMM.From = "xx*****@xxxxxxx.com"
>>>
>>'send in html format
>>>
>>objMM.BodyFormat = MailFormat.html
>>>
>>'Set the priority - options are High, Low, and Normal
>>>
>>objMM.Priority = MailPriority.Normal
>>>
>>'Set the subject
>>>
>>objMM.Subject = "Accident Investigation Form"
>>>
>>>
>>'Set the body
>>>
>>objMM.Body = DateTime.Now + " HI " & _
>>>
>>"<html>" & vbCrLf & vbCrLf & _
>>>
>>"<head>" & vbCrLf & vbCrLf & _
>>>
>>"</head>"& vbCrLf & vbCrLf & _
>>>
>>"<body>" & vbCrLf & vbCrLf & _
>>>
>>Location where accident occurred:
>>>
>>Location.Text & _
>>>
>>"<br>"& _
>>>
>7Check1.Text & "." & vbCrLf & vbCrLf & _
>>>
>>vbCrLf &vbCrLf & _
>>>
>>Check2.Text & vbCrLf & _
>>>
>>"</td>" & vbCrLf & vbCrLf & _
>>>
>>"</body>" & vbCrLf & vbCrLf & _
>>>
>>"</html>"
>>>
>>>
>>'Specify to use the default Smtp Server
>>>
>>SmtpMail.SmtpServer = ""
>>>
>>'Now, to send the message, use the Send method of the SmtpMail class
>>>
>>SmtpMail.Send(objMM)
>>>
>>panelSendEmail.Visible = false
>>>
>>panelMailSent.Visible = true
>>>
>>End Sub
>>>
>>>
>>>
>></script>
>>>
>></head>
>>>
>>>
>><body>
>>>
>><table width="750" bgcolor="#E9EDF4" table border="1"
>>cellpadding="3">
>>>
>><h3><center><font face="Verdana">Wheeler's Accident Investigation
>>Form</font></h3>
>>>
>>>
>>>
>><hr>
>>>
>><%--__________________________________________________ __________________________--%>
>>>
>><%--ROW 1--%>
>>>
>>>
>><td width="250" valign="top">
>>>
>>>
>><form runat="server">
>>>
>><font face="Verdana" Size="2">
>>>
>>Location where accident occurred: <asp:textbox id="Location"
>>runat=server Width="200"/>
>>>
>></td>
>>>
>><td align="right" valign="top" width="225">
>>>
>>>
>><font face="Verdana" Size="2">Employer's Premises
>>>
>>>
>>>
>><asp:CheckBox id=Check1 Text="yes" runat="server" />
>>>
>><asp:CheckBox id=Check2 Text="no" runat="server" />
>>>
>><br>
>>>
>>>
>>Job site
>>>
>><asp:CheckBox id=Check3 Text="yes" runat="server" />
>>>
>><asp:CheckBox id=Check4 Text="no" runat="server" />
>>>
>>>
>></td>
>>>
>><td>
>>>
>><font face="Verdana" Size="2">Date of accident</font><br>
>>>
>><asp:textbox id="Date" runat=server Width="100"/>
>>>
>>>
>></td>
>>>
>><%--__________________________________________________ __________________________--%>
>>>
>><%--ROW 2--%>
>>>
>>>
>><tr<td>
>>>
>><font face="Verdana" Size="2">Who was injured?</font><br>
>>>
>><asp:textbox id="Who" runat=server width="200"/>
>>>
>></td>
>>>
>><td align= "left">
>>>
>><font face="Verdana" Size="2">Employee <asp:CheckBox id=Check5
>>runat="server" />
>>>
>><br>
>>>
>>Non-employee <asp:CheckBox id=Check6 runat="server" />
>>>
>>>
>></td>
>>>
>><td align="right"><font face="Verdana" Size="2">
>>>
>>Time of accident a.m. <asp:textbox id="am" runat=server Width="90"/>
>>>
>>p.m. <asp:textbox id="pm" runat=server Width="90"/>
>>>
>></TD>
>>>
>><%--__________________________________________________ __________________________--%>
>>>
>><%--ROW 3--%>
>>>
>><tr>
>>>
>><td>
>>>
>><font face="Verdana" Size="2">Date of Hire <br<asp:textbox
>>id="Hiredate" runat=server/>
>>>
>></td>
>>>
>><td>
>>>
>><font face="Verdana" Size="2">Job Title or Occupation
>><br><asp:textbox id="occupation"
>>runat=server width="200"/>
>>>
>></td>
>>>
>><td>
>>>
>><font face="Verdana" Size="2">How long has employee worked at job
>>where injury
>>occurred?<br><asp:textbox id="lengthofjob" runat=server/>
>>>
>></td>
>>>
>><%--__________________________________________________ __________________________--%>
>>>
>><%--Row 4--%>
>>>
>>&nbsp&nbsp
>>>
>>>
>>>
>><p>
>>>
>>>
>><asp:Label id=Label1 font-name="arial" font-size="10pt"
>>runat="server"/>
>>>
>><!Copied from /smirnof>
>>>
>><asp:panel id="panelSendEmail" runat="server">
>>>
>>>
>>>
>>>
>>>
>><%--asp:textbox id= runat="server" /--%>
>>>
>><br>
>>>
>><b>Your Message:</b><br>
>>>
>><%--asp:textbox id="txtMessage" TextMode="MultiLine"
>>>
>>Columns="40" Rows="10" runat="server" /--%>
>>>
>><p>
>>>
>>>
>>>
>><asp:button runat="server" id="btnSendFeedback" Text="Send
>>>
>>Feedback!"
>>>
>>OnClick="btnSendFeedback_Click" />
>>>
>>>
>>>
>></asp:panel>
>>>
>><asp:panel id="panelMailSent" runat="server" Visible="False">
>>>
>>An email has been sent to the email address you specified.
>>>
>>Thanks!
>>>
>></asp:panel>
>>>
>></form>
>>>
>></body>
>>>
>></html>
>>>
>>>
>>
>>
>
>
>




May 10 '07 #14

P: n/a
Also, David,
I had asked why do I get this error message:
Compiler Error Message: BC30452: Operator '&' is not defined for types
String' and 'System.Web.UI.WebControls.TextBox'.

A part of Juan's reply was Something else : you *must* put all the HTML
content in ONE line.

Do you have any thoughts on that error message?
"David" <da*****************@revilloc.REMOVETHIS.comwrot e in message
news:ux**************@TK2MSFTNGP03.phx.gbl...
Ah,

Sorry, I have my newsreader on to ignore read messages.

The P tags break the lines in the rendered page. BR tags also break lines
(work as a hard wrap).

vbCrLf is a Visual Basic Carriage Return Line Feed. All this does is allow
the source html wrap onto a new line, so that your line is not too long.

If you want to use the same thing in C#, then it is something like...

email.Body = "This is my email body\nNow I am on a new line\nNote the
backslash and n to create a new line\n. I can't remember though, you might
need \r\n to create a new line";

backslash n.

Is that what you looking for? This however doesn't affect your rendered
output. use \n where there is vbcrlf, however, vbcrlf is a defined
constant, and \n has to be in quotes.

What you could do though is...

string vbCrLf = "\n";

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"dancer" <da****@microsoft.comwrote in message
news:u3**************@TK2MSFTNGP04.phx.gbl...
>David,

Not exactly does this answer my question. Could you please check out
Juan's answer to my first post on this subject and help me understand,
since I was copying my code from this code.

Thank you.
"David" <da*****************@revilloc.REMOVETHIS.comwrot e in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>>The vbCrLf are purely to ensure that the line is not too long when
generated. There is a problem with over long lines that when they do
eventually wrap, it can disrupt your formatted email.

You will note that there are no br tags, but there are p tags <pand
</p>. These are what cause <P>aragraph breaks. (Actually, they are for
new paragraphs rather than breaking paragraphs).

Does this answer your question?

(Note, you probably can't press "Yes" below as you probably can't see
it. If you can, then you have better eyes than me, as I can't see it.
:-)

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available

"dancer" <da****@microsoft.comwrote in message
news:uH**************@TK2MSFTNGP04.phx.gbl...
Hi Juan,

What is the difference in what I am trying to do and this? Why can
THEY break up the HTML content into different lines?

email_html.aspx
--------------------------------------------------------------------------------

<%@ Page Language="VB" ClientTarget="downlevel" %>
<%@ Import Namespace="System.Web.Mail" %>
<script language="VB" runat="server">
Sub btnSendMail_OnClick(Source As Object, E As EventArgs)
Dim myMessage As New MailMessage
Dim myMail As SmtpMail
Dim strEmail As String

If Page.IsValid() Then
strEmail = txtEmail.Text

'myMessage.From = "webmaster@" &
Request.ServerVariables("SERVER_NAME")
myMessage.From = "we*******@asp101.com"
myMessage.To = strEmail
myMessage.Subject = "E-mail Sample (HTML) from ASP 101!"

' This is the magic line. Without this the message will just appear
' as plain HTML and won't be rendered by the recipient's email client.
' It'd be as if they did "View Source" on a web page.
MyMessage.BodyFormat = MailFormat.Html

' This is multi-lined simply for readability.
' Notice that it is a properly formatted HTML
' message and not just plain text like most email.
' A lot of people have asked how to use form data
' in the emails so I added an example of including
' the entered address in the body of the email.
myMessage.Body = "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0
Transitional//EN"">" & vbCrLf _
& "<html>" & vbCrLf _
& "<head>" & vbCrLf _
& " <title>Sample Message From ASP 101</title>" & vbCrLf _
& " <meta http-equiv=Content-Type content=""text/html;
charset=iso-8859-1"">" & vbCrLf _
& "</head>" & vbCrLf _
& "<body bgcolor=""#FFFFCC"">" & vbCrLf _
& " <h2>Sample Message From ASP 101</h2>" & vbCrLf _
& " <p>" & vbCrLf _
& " This message was sent from a sample at" & vbCrLf _
& " <a href=""http://www.asp101.com"">ASP 101</a>." & vbCrLf _
& " It is used to show people how to send HTML" & vbCrLf _
& " formatted email from an ASP.NET page." & vbCrLf _
& " If you did not request this email yourself," & vbCrLf _
& " your address was entered by one of our" & vbCrLf _
& " visitors." & vbCrLf _
& " <strong>" & vbCrLf _
& " We do not store these e-mail addresses." & vbCrLf _
& " </strong>" & vbCrLf _
& " </p>" & vbCrLf _
& " <p><font size=""-1"">Please address all concerns to
we*******@asp101.com.</font></p>" & vbCrLf _
& " <p><font size=""-1"">This message was sent to: " & strEmail &
"</font></p>" & vbCrLf _
& "</body>" & vbCrLf _
& "</html>" & vbCrLf

' Doesn't have to be local... just enter your
' SMTP server's name or ip address!
myMail.SmtpServer = "localhost"
myMail.Send(myMessage)

frmEmail.Visible = False
lblUserMessage.Text = "An HTML-formatted email message has been sent to
" & strEmail & "."
End If
End Sub
</script>

<html>
<head>
<title>ASP.NET Email (HTML Format) Sample</title>
</head>
<body>

<asp:Label id="lblUserMessage" text="Enter your e-mail address:"
runat="server" />
<form method="post" id="frmEmail" runat="server">
<asp:TextBox id="txtEmail" size="30" runat="server" />
<asp:RequiredFieldValidator runat="server"
id="validEmailRequired" ControlToValidate="txtEmail"
errormessage="Please enter an email address."
display="Dynamic" />
<asp:RegularExpressionValidator runat="server"
id="validEmailRegExp" ControlToValidate="txtEmail"
ValidationExpression="^[\w-]+@[\w-]+\.(com|net|org|edu|mil)$"
errormessage="Please enter a valid email address."
Display="Dynamic" />

<asp:Button id="btnSendMail" text="Send Mail!"
OnClick="btnSendMail_OnClick" runat="server" />
</form>

<hr />

<p>
Click <a
href="http://www.asp101.com/samples/email_html_aspx.asp">here</ato
read about and download the source code.
</p>

</body>
</html>
--------------------------------------------------------------------------------

"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl. ..
You don't need to set the html/head/body tags within the HTML body
...and, in the VbCrLf thread, we established that you can't use VbCrLf
in HTML.
>
Something else : you *must* put all the HTML content in ONE line.
You can't break the lines with code.
>
Get rid of all the "VbCrLf" and all the "&" and write all your HTML in
a single line,
line-breaking the body's content with "<br />" or "<P... </P>" as
needed.
>
Also, you can't insert Textbox controls into your HTML.
>
So, Check1.Text is out, too.
>
If you want to reference their content, after a user fills them out,
capture it to a variable and use that, before writing to the body.
>
insert :
>
Dim Check1 as String = Check1.Text
Dim Check2 as String = Check2.Text
Dim Location as String = Location.Text
before "Dim objMM as New MailMessage()"
>
and, when composing the body, use :
>
mail.Body="Hi, <p>The location where the accident occurred is :" &
Location & "<br/>" & Check1 & "."
' etc.
>
You *can* use the & to reference text variables.
Notice the location of the quote marks.
>
>
>
>
>
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"dancer" <da****@microsoft.comwrote in message
news:uU*************@TK2MSFTNGP05.phx.gbl...
>Can somebody tell me why I get this message with the following code?
>>
>Compiler Error Message: BC30452: Operator '&' is not defined for
>types 'String' and
>'System.Web.UI.WebControls.TextBox'.
>>
><html>
>>
><head>
>>
><% @Import Namespace="System.Web.Mail" %>
>>
><script language="VB" runat="server">
>>
>>
>>
>Sub btnSendFeedback_Click(sender as Object, e as EventArgs)
>>
>'Create an instance of the MailMessage class
>>
>Dim objMM as New MailMessage()
>>
>'Set the properties - send the email to the person who filled out the
>>
>'feedback form.
>>
>objMM.To = "xx*****@xxxxxxx.com"
>>
>>
>objMM.From = "xx*****@xxxxxxx.com"
>>
>'send in html format
>>
>objMM.BodyFormat = MailFormat.html
>>
>'Set the priority - options are High, Low, and Normal
>>
>objMM.Priority = MailPriority.Normal
>>
>'Set the subject
>>
>objMM.Subject = "Accident Investigation Form"
>>
>>
>'Set the body
>>
>objMM.Body = DateTime.Now + " HI " & _
>>
>"<html>" & vbCrLf & vbCrLf & _
>>
>"<head>" & vbCrLf & vbCrLf & _
>>
>"</head>"& vbCrLf & vbCrLf & _
>>
>"<body>" & vbCrLf & vbCrLf & _
>>
>Location where accident occurred:
>>
>Location.Text & _
>>
>"<br>"& _
>>
7Check1.Text & "." & vbCrLf & vbCrLf & _
>>
>vbCrLf &vbCrLf & _
>>
>Check2.Text & vbCrLf & _
>>
>"</td>" & vbCrLf & vbCrLf & _
>>
>"</body>" & vbCrLf & vbCrLf & _
>>
>"</html>"
>>
>>
>'Specify to use the default Smtp Server
>>
>SmtpMail.SmtpServer = ""
>>
>'Now, to send the message, use the Send method of the SmtpMail class
>>
>SmtpMail.Send(objMM)
>>
>panelSendEmail.Visible = false
>>
>panelMailSent.Visible = true
>>
>End Sub
>>
>>
>>
></script>
>>
></head>
>>
>>
><body>
>>
><table width="750" bgcolor="#E9EDF4" table border="1"
>cellpadding="3">
>>
><h3><center><font face="Verdana">Wheeler's Accident Investigation
>Form</font></h3>
>>
>>
>>
><hr>
>>
><%--__________________________________________________ __________________________--%>
>>
><%--ROW 1--%>
>>
>>
><td width="250" valign="top">
>>
>>
><form runat="server">
>>
><font face="Verdana" Size="2">
>>
>Location where accident occurred: <asp:textbox id="Location"
>runat=server Width="200"/>
>>
></td>
>>
><td align="right" valign="top" width="225">
>>
>>
><font face="Verdana" Size="2">Employer's Premises
>>
>>
>>
><asp:CheckBox id=Check1 Text="yes" runat="server" />
>>
><asp:CheckBox id=Check2 Text="no" runat="server" />
>>
><br>
>>
>>
>Job site
>>
><asp:CheckBox id=Check3 Text="yes" runat="server" />
>>
><asp:CheckBox id=Check4 Text="no" runat="server" />
>>
>>
></td>
>>
><td>
>>
><font face="Verdana" Size="2">Date of accident</font><br>
>>
><asp:textbox id="Date" runat=server Width="100"/>
>>
>>
></td>
>>
><%--__________________________________________________ __________________________--%>
>>
><%--ROW 2--%>
>>
>>
><tr<td>
>>
><font face="Verdana" Size="2">Who was injured?</font><br>
>>
><asp:textbox id="Who" runat=server width="200"/>
>>
></td>
>>
><td align= "left">
>>
><font face="Verdana" Size="2">Employee <asp:CheckBox id=Check5
>runat="server" />
>>
><br>
>>
>Non-employee <asp:CheckBox id=Check6 runat="server" />
>>
>>
></td>
>>
><td align="right"><font face="Verdana" Size="2">
>>
>Time of accident a.m. <asp:textbox id="am" runat=server Width="90"/>
>>
>p.m. <asp:textbox id="pm" runat=server Width="90"/>
>>
></TD>
>>
><%--__________________________________________________ __________________________--%>
>>
><%--ROW 3--%>
>>
><tr>
>>
><td>
>>
><font face="Verdana" Size="2">Date of Hire <br<asp:textbox
>id="Hiredate" runat=server/>
>>
></td>
>>
><td>
>>
><font face="Verdana" Size="2">Job Title or Occupation
><br><asp:textbox id="occupation"
>runat=server width="200"/>
>>
></td>
>>
><td>
>>
><font face="Verdana" Size="2">How long has employee worked at job
>where injury
>occurred?<br><asp:textbox id="lengthofjob" runat=server/>
>>
></td>
>>
><%--__________________________________________________ __________________________--%>
>>
><%--Row 4--%>
>>
>&nbsp&nbsp
>>
>>
>>
><p>
>>
>>
><asp:Label id=Label1 font-name="arial" font-size="10pt"
>runat="server"/>
>>
><!Copied from /smirnof>
>>
><asp:panel id="panelSendEmail" runat="server">
>>
>>
>>
>>
>>
><%--asp:textbox id= runat="server" /--%>
>>
><br>
>>
><b>Your Message:</b><br>
>>
><%--asp:textbox id="txtMessage" TextMode="MultiLine"
>>
>Columns="40" Rows="10" runat="server" /--%>
>>
><p>
>>
>>
>>
><asp:button runat="server" id="btnSendFeedback" Text="Send
>>
>Feedback!"
>>
>OnClick="btnSendFeedback_Click" />
>>
>>
>>
></asp:panel>
>>
><asp:panel id="panelMailSent" runat="server" Visible="False">
>>
>An email has been sent to the email address you specified.
>>
>Thanks!
>>
></asp:panel>
>>
></form>
>>
></body>
>>
></html>
>>
>>
>
>





May 10 '07 #15

P: n/a
Cowboy,

Because I don't know what I'm doing.
I had created a form in ASP.NET that worked well.
I wanted to email the results, and that worked also.
But I wanted the email results to be formatted nicely, just like the
original form in which somebody would enter the data.
Somebody sent me to ASP101.com. There I clicked source code in Asp.net. I
studied their code and copied their method (I thought).
So here I am, confused.
How would YOU go about making the email nicely formatted?

"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamMwrote in
message news:D1**********************************@microsof t.com...
You have the br run right up against an ampersand, which could be your
issue.

My question is why you are building the page like an ASP page instead of
an ASP.NET page? In other words, why build when you can bind?

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com

*********************************************
Think outside the box!
*********************************************
"dancer" <da****@microsoft.comwrote in message
news:uU*************@TK2MSFTNGP05.phx.gbl...
>Can somebody tell me why I get this message with the following code?

Compiler Error Message: BC30452: Operator '&' is not defined for types
'String' and 'System.Web.UI.WebControls.TextBox'.

<html>

<head>

<% @Import Namespace="System.Web.Mail" %>

<script language="VB" runat="server">

Sub btnSendFeedback_Click(sender as Object, e as EventArgs)

'Create an instance of the MailMessage class

Dim objMM as New MailMessage()

'Set the properties - send the email to the person who filled out the

'feedback form.

objMM.To = "xx*****@xxxxxxx.com"
objMM.From = "xx*****@xxxxxxx.com"

'send in html format

objMM.BodyFormat = MailFormat.html

'Set the priority - options are High, Low, and Normal

objMM.Priority = MailPriority.Normal

'Set the subject

objMM.Subject = "Accident Investigation Form"
'Set the body

objMM.Body = DateTime.Now + " HI " & _

"<html>" & vbCrLf & vbCrLf & _

"<head>" & vbCrLf & vbCrLf & _

"</head>"& vbCrLf & vbCrLf & _

"<body>" & vbCrLf & vbCrLf & _

Location where accident occurred:

Location.Text & _

"<br>"& _

Check1.Text & "." & vbCrLf & vbCrLf & _

vbCrLf &vbCrLf & _

Check2.Text & vbCrLf & _

"</td>" & vbCrLf & vbCrLf & _

"</body>" & vbCrLf & vbCrLf & _

"</html>"
'Specify to use the default Smtp Server

SmtpMail.SmtpServer = ""

'Now, to send the message, use the Send method of the SmtpMail class

SmtpMail.Send(objMM)

panelSendEmail.Visible = false

panelMailSent.Visible = true

End Sub

</script>

</head>
<body>

<table width="750" bgcolor="#E9EDF4" table border="1" cellpadding="3">

<h3><center><font face="Verdana">Wheeler's Accident Investigation
Form</font></h3>

<hr>

<%--__________________________________________________ __________________________--%>

<%--ROW 1--%>
<td width="250" valign="top">
<form runat="server">

<font face="Verdana" Size="2">

Location where accident occurred: <asp:textbox id="Location" runat=server
Width="200"/>

</td>

<td align="right" valign="top" width="225">
<font face="Verdana" Size="2">Employer's Premises

<asp:CheckBox id=Check1 Text="yes" runat="server" />

<asp:CheckBox id=Check2 Text="no" runat="server" />

<br>
Job site

<asp:CheckBox id=Check3 Text="yes" runat="server" />

<asp:CheckBox id=Check4 Text="no" runat="server" />
</td>

<td>

<font face="Verdana" Size="2">Date of accident</font><br>

<asp:textbox id="Date" runat=server Width="100"/>
</td>

<%--__________________________________________________ __________________________--%>

<%--ROW 2--%>
<tr<td>

<font face="Verdana" Size="2">Who was injured?</font><br>

<asp:textbox id="Who" runat=server width="200"/>

</td>

<td align= "left">

<font face="Verdana" Size="2">Employee <asp:CheckBox id=Check5
runat="server" />

<br>

Non-employee <asp:CheckBox id=Check6 runat="server" />
</td>

<td align="right"><font face="Verdana" Size="2">

Time of accident a.m. <asp:textbox id="am" runat=server Width="90"/>

p.m. <asp:textbox id="pm" runat=server Width="90"/>

</TD>

<%--__________________________________________________ __________________________--%>

<%--ROW 3--%>

<tr>

<td>

<font face="Verdana" Size="2">Date of Hire <br<asp:textbox
id="Hiredate" runat=server/>

</td>

<td>

<font face="Verdana" Size="2">Job Title or Occupation <br><asp:textbox
id="occupation" runat=server width="200"/>

</td>

<td>

<font face="Verdana" Size="2">How long has employee worked at job where
injury occurred?<br><asp:textbox id="lengthofjob" runat=server/>

</td>

<%--__________________________________________________ __________________________--%>

<%--Row 4--%>

&nbsp&nbsp

<p>
<asp:Label id=Label1 font-name="arial" font-size="10pt" runat="server"/>

<!Copied from /smirnof>

<asp:panel id="panelSendEmail" runat="server">

<%--asp:textbox id= runat="server" /--%>

<br>

<b>Your Message:</b><br>

<%--asp:textbox id="txtMessage" TextMode="MultiLine"

Columns="40" Rows="10" runat="server" /--%>

<p>

<asp:button runat="server" id="btnSendFeedback" Text="Send

Feedback!"

OnClick="btnSendFeedback_Click" />

</asp:panel>

<asp:panel id="panelMailSent" runat="server" Visible="False">

An email has been sent to the email address you specified.

Thanks!

</asp:panel>

</form>

</body>

</html>


May 10 '07 #16

P: n/a
Juan is correct, but I can understand why it is confusing you.

The & is a VB concatenation operator. In C#, the concatenation operator is +

Where there is &, put a +

Where there is vbCrLf put "\n" (or create a string called vbCrLf and assign
"\n" to that string)

When sending the message in email, your mail.Body has to have the string you
want to send effectively in one line. In VB, you achieve that by putting &
to join the strings togethor.

In C#, you use the + (as mentioned above.)

However, you can build the string prior to sticking it in the mail.Body.
This is where the += helps.

e.g.
// NOTE, This is C#
string MyString = "Dave ";
MyString += "Colliver ";

Response.Write(MyString); // Writes "Dave Colliver" to the screen.

What that has effectively done is to create one line. That line is called
MyString.

Does this help?

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"dancer" <da****@microsoft.comwrote in message
news:u9**************@TK2MSFTNGP05.phx.gbl...
Also, David,
I had asked why do I get this error message:
Compiler Error Message: BC30452: Operator '&' is not defined for types
String' and 'System.Web.UI.WebControls.TextBox'.

A part of Juan's reply was Something else : you *must* put all the HTML
content in ONE line.

Do you have any thoughts on that error message?
"David" <da*****************@revilloc.REMOVETHIS.comwrot e in message
news:ux**************@TK2MSFTNGP03.phx.gbl...
>Ah,

Sorry, I have my newsreader on to ignore read messages.

The P tags break the lines in the rendered page. BR tags also break lines
(work as a hard wrap).

vbCrLf is a Visual Basic Carriage Return Line Feed. All this does is
allow the source html wrap onto a new line, so that your line is not too
long.

If you want to use the same thing in C#, then it is something like...

email.Body = "This is my email body\nNow I am on a new line\nNote the
backslash and n to create a new line\n. I can't remember though, you
might need \r\n to create a new line";

backslash n.

Is that what you looking for? This however doesn't affect your rendered
output. use \n where there is vbcrlf, however, vbcrlf is a defined
constant, and \n has to be in quotes.

What you could do though is...

string vbCrLf = "\n";

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"dancer" <da****@microsoft.comwrote in message
news:u3**************@TK2MSFTNGP04.phx.gbl...
>>David,

Not exactly does this answer my question. Could you please check out
Juan's answer to my first post on this subject and help me understand,
since I was copying my code from this code.

Thank you.
"David" <da*****************@revilloc.REMOVETHIS.comwrot e in message
news:%2****************@TK2MSFTNGP02.phx.gbl.. .
The vbCrLf are purely to ensure that the line is not too long when
generated. There is a problem with over long lines that when they do
eventually wrap, it can disrupt your formatted email.

You will note that there are no br tags, but there are p tags <pand
</p>. These are what cause <P>aragraph breaks. (Actually, they are for
new paragraphs rather than breaking paragraphs).

Does this answer your question?

(Note, you probably can't press "Yes" below as you probably can't see
it. If you can, then you have better eyes than me, as I can't see it.
:-)

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available

"dancer" <da****@microsoft.comwrote in message
news:uH**************@TK2MSFTNGP04.phx.gbl...
Hi Juan,
>
What is the difference in what I am trying to do and this? Why can
THEY break up the HTML content into different lines?
>
email_html.aspx
--------------------------------------------------------------------------------
>
<%@ Page Language="VB" ClientTarget="downlevel" %>
<%@ Import Namespace="System.Web.Mail" %>
<script language="VB" runat="server">
Sub btnSendMail_OnClick(Source As Object, E As EventArgs)
Dim myMessage As New MailMessage
Dim myMail As SmtpMail
Dim strEmail As String
>
If Page.IsValid() Then
strEmail = txtEmail.Text
>
'myMessage.From = "webmaster@" &
Request.ServerVariables("SERVER_NAME")
myMessage.From = "we*******@asp101.com"
myMessage.To = strEmail
myMessage.Subject = "E-mail Sample (HTML) from ASP 101!"
>
' This is the magic line. Without this the message will just appear
' as plain HTML and won't be rendered by the recipient's email client.
' It'd be as if they did "View Source" on a web page.
MyMessage.BodyFormat = MailFormat.Html
>
' This is multi-lined simply for readability.
' Notice that it is a properly formatted HTML
' message and not just plain text like most email.
' A lot of people have asked how to use form data
' in the emails so I added an example of including
' the entered address in the body of the email.
myMessage.Body = "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0
Transitional//EN"">" & vbCrLf _
& "<html>" & vbCrLf _
& "<head>" & vbCrLf _
& " <title>Sample Message From ASP 101</title>" & vbCrLf _
& " <meta http-equiv=Content-Type content=""text/html;
charset=iso-8859-1"">" & vbCrLf _
& "</head>" & vbCrLf _
& "<body bgcolor=""#FFFFCC"">" & vbCrLf _
& " <h2>Sample Message From ASP 101</h2>" & vbCrLf _
& " <p>" & vbCrLf _
& " This message was sent from a sample at" & vbCrLf _
& " <a href=""http://www.asp101.com"">ASP 101</a>." & vbCrLf _
& " It is used to show people how to send HTML" & vbCrLf _
& " formatted email from an ASP.NET page." & vbCrLf _
& " If you did not request this email yourself," & vbCrLf _
& " your address was entered by one of our" & vbCrLf _
& " visitors." & vbCrLf _
& " <strong>" & vbCrLf _
& " We do not store these e-mail addresses." & vbCrLf _
& " </strong>" & vbCrLf _
& " </p>" & vbCrLf _
& " <p><font size=""-1"">Please address all concerns to
we*******@asp101.com.</font></p>" & vbCrLf _
& " <p><font size=""-1"">This message was sent to: " & strEmail &
"</font></p>" & vbCrLf _
& "</body>" & vbCrLf _
& "</html>" & vbCrLf
>
' Doesn't have to be local... just enter your
' SMTP server's name or ip address!
myMail.SmtpServer = "localhost"
myMail.Send(myMessage)
>
frmEmail.Visible = False
lblUserMessage.Text = "An HTML-formatted email message has been sent
to " & strEmail & "."
End If
End Sub
</script>
>
<html>
<head>
<title>ASP.NET Email (HTML Format) Sample</title>
</head>
<body>
>
<asp:Label id="lblUserMessage" text="Enter your e-mail address:"
runat="server" />
<form method="post" id="frmEmail" runat="server">
<asp:TextBox id="txtEmail" size="30" runat="server" />
<asp:RequiredFieldValidator runat="server"
id="validEmailRequired" ControlToValidate="txtEmail"
errormessage="Please enter an email address."
display="Dynamic" />
<asp:RegularExpressionValidator runat="server"
id="validEmailRegExp" ControlToValidate="txtEmail"
ValidationExpression="^[\w-]+@[\w-]+\.(com|net|org|edu|mil)$"
errormessage="Please enter a valid email address."
Display="Dynamic" />
>
<asp:Button id="btnSendMail" text="Send Mail!"
OnClick="btnSendMail_OnClick" runat="server" />
</form>
>
<hr />
>
<p>
Click <a
href="http://www.asp101.com/samples/email_html_aspx.asp">here</ato
read about and download the source code.
</p>
>
</body>
</html>
>
>
--------------------------------------------------------------------------------
>
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl.. .
>You don't need to set the html/head/body tags within the HTML body
>...and, in the VbCrLf thread, we established that you can't use
>VbCrLf in HTML.
>>
>Something else : you *must* put all the HTML content in ONE line.
>You can't break the lines with code.
>>
>Get rid of all the "VbCrLf" and all the "&" and write all your HTML
>in a single line,
>line-breaking the body's content with "<br />" or "<P... </P>" as
>needed.
>>
>Also, you can't insert Textbox controls into your HTML.
>>
>So, Check1.Text is out, too.
>>
>If you want to reference their content, after a user fills them out,
>capture it to a variable and use that, before writing to the body.
>>
>insert :
>>
>Dim Check1 as String = Check1.Text
>Dim Check2 as String = Check2.Text
>Dim Location as String = Location.Text
>before "Dim objMM as New MailMessage()"
>>
>and, when composing the body, use :
>>
>mail.Body="Hi, <p>The location where the accident occurred is :" &
>Location & "<br/>" & Check1 & "."
>' etc.
>>
>You *can* use the & to reference text variables.
>Notice the location of the quote marks.
>>
>>
>>
>>
>>
>Juan T. Llibre, asp.net MVP
>asp.net faq : http://asp.net.do/faq/
>foros de asp.net, en español : http://asp.net.do/foros/
>===================================
>"dancer" <da****@microsoft.comwrote in message
>news:uU*************@TK2MSFTNGP05.phx.gbl.. .
>>Can somebody tell me why I get this message with the following code?
>>>
>>Compiler Error Message: BC30452: Operator '&' is not defined for
>>types 'String' and
>>'System.Web.UI.WebControls.TextBox'.
>>>
>><html>
>>>
>><head>
>>>
>><% @Import Namespace="System.Web.Mail" %>
>>>
>><script language="VB" runat="server">
>>>
>>>
>>>
>>Sub btnSendFeedback_Click(sender as Object, e as EventArgs)
>>>
>>'Create an instance of the MailMessage class
>>>
>>Dim objMM as New MailMessage()
>>>
>>'Set the properties - send the email to the person who filled out
>>the
>>>
>>'feedback form.
>>>
>>objMM.To = "xx*****@xxxxxxx.com"
>>>
>>>
>>objMM.From = "xx*****@xxxxxxx.com"
>>>
>>'send in html format
>>>
>>objMM.BodyFormat = MailFormat.html
>>>
>>'Set the priority - options are High, Low, and Normal
>>>
>>objMM.Priority = MailPriority.Normal
>>>
>>'Set the subject
>>>
>>objMM.Subject = "Accident Investigation Form"
>>>
>>>
>>'Set the body
>>>
>>objMM.Body = DateTime.Now + " HI " & _
>>>
>>"<html>" & vbCrLf & vbCrLf & _
>>>
>>"<head>" & vbCrLf & vbCrLf & _
>>>
>>"</head>"& vbCrLf & vbCrLf & _
>>>
>>"<body>" & vbCrLf & vbCrLf & _
>>>
>>Location where accident occurred:
>>>
>>Location.Text & _
>>>
>>"<br>"& _
>>>
>7Check1.Text & "." & vbCrLf & vbCrLf & _
>>>
>>vbCrLf &vbCrLf & _
>>>
>>Check2.Text & vbCrLf & _
>>>
>>"</td>" & vbCrLf & vbCrLf & _
>>>
>>"</body>" & vbCrLf & vbCrLf & _
>>>
>>"</html>"
>>>
>>>
>>'Specify to use the default Smtp Server
>>>
>>SmtpMail.SmtpServer = ""
>>>
>>'Now, to send the message, use the Send method of the SmtpMail class
>>>
>>SmtpMail.Send(objMM)
>>>
>>panelSendEmail.Visible = false
>>>
>>panelMailSent.Visible = true
>>>
>>End Sub
>>>
>>>
>>>
>></script>
>>>
>></head>
>>>
>>>
>><body>
>>>
>><table width="750" bgcolor="#E9EDF4" table border="1"
>>cellpadding="3">
>>>
>><h3><center><font face="Verdana">Wheeler's Accident Investigation
>>Form</font></h3>
>>>
>>>
>>>
>><hr>
>>>
>><%--__________________________________________________ __________________________--%>
>>>
>><%--ROW 1--%>
>>>
>>>
>><td width="250" valign="top">
>>>
>>>
>><form runat="server">
>>>
>><font face="Verdana" Size="2">
>>>
>>Location where accident occurred: <asp:textbox id="Location"
>>runat=server Width="200"/>
>>>
>></td>
>>>
>><td align="right" valign="top" width="225">
>>>
>>>
>><font face="Verdana" Size="2">Employer's Premises
>>>
>>>
>>>
>><asp:CheckBox id=Check1 Text="yes" runat="server" />
>>>
>><asp:CheckBox id=Check2 Text="no" runat="server" />
>>>
>><br>
>>>
>>>
>>Job site
>>>
>><asp:CheckBox id=Check3 Text="yes" runat="server" />
>>>
>><asp:CheckBox id=Check4 Text="no" runat="server" />
>>>
>>>
>></td>
>>>
>><td>
>>>
>><font face="Verdana" Size="2">Date of accident</font><br>
>>>
>><asp:textbox id="Date" runat=server Width="100"/>
>>>
>>>
>></td>
>>>
>><%--__________________________________________________ __________________________--%>
>>>
>><%--ROW 2--%>
>>>
>>>
>><tr<td>
>>>
>><font face="Verdana" Size="2">Who was injured?</font><br>
>>>
>><asp:textbox id="Who" runat=server width="200"/>
>>>
>></td>
>>>
>><td align= "left">
>>>
>><font face="Verdana" Size="2">Employee <asp:CheckBox id=Check5
>>runat="server" />
>>>
>><br>
>>>
>>Non-employee <asp:CheckBox id=Check6 runat="server" />
>>>
>>>
>></td>
>>>
>><td align="right"><font face="Verdana" Size="2">
>>>
>>Time of accident a.m. <asp:textbox id="am" runat=server Width="90"/>
>>>
>>p.m. <asp:textbox id="pm" runat=server Width="90"/>
>>>
>></TD>
>>>
>><%--__________________________________________________ __________________________--%>
>>>
>><%--ROW 3--%>
>>>
>><tr>
>>>
>><td>
>>>
>><font face="Verdana" Size="2">Date of Hire <br<asp:textbox
>>id="Hiredate" runat=server/>
>>>
>></td>
>>>
>><td>
>>>
>><font face="Verdana" Size="2">Job Title or Occupation
>><br><asp:textbox id="occupation"
>>runat=server width="200"/>
>>>
>></td>
>>>
>><td>
>>>
>><font face="Verdana" Size="2">How long has employee worked at job
>>where injury
>>occurred?<br><asp:textbox id="lengthofjob" runat=server/>
>>>
>></td>
>>>
>><%--__________________________________________________ __________________________--%>
>>>
>><%--Row 4--%>
>>>
>>&nbsp&nbsp
>>>
>>>
>>>
>><p>
>>>
>>>
>><asp:Label id=Label1 font-name="arial" font-size="10pt"
>>runat="server"/>
>>>
>><!Copied from /smirnof>
>>>
>><asp:panel id="panelSendEmail" runat="server">
>>>
>>>
>>>
>>>
>>>
>><%--asp:textbox id= runat="server" /--%>
>>>
>><br>
>>>
>><b>Your Message:</b><br>
>>>
>><%--asp:textbox id="txtMessage" TextMode="MultiLine"
>>>
>>Columns="40" Rows="10" runat="server" /--%>
>>>
>><p>
>>>
>>>
>>>
>><asp:button runat="server" id="btnSendFeedback" Text="Send
>>>
>>Feedback!"
>>>
>>OnClick="btnSendFeedback_Click" />
>>>
>>>
>>>
>></asp:panel>
>>>
>><asp:panel id="panelMailSent" runat="server" Visible="False">
>>>
>>An email has been sent to the email address you specified.
>>>
>>Thanks!
>>>
>></asp:panel>
>>>
>></form>
>>>
>></body>
>>>
>></html>
>>>
>>>
>>
>>
>
>
>




May 10 '07 #17

P: n/a
re:
!A part of Juan's reply was Something else : you *must* put all the HTML
!content in ONE line.

I meant : "all the HTML content in ONE line".

The sample at ASP101 places all the HTML content in ONE line,
even though it composes that single line in several lines.

That's why you need to use VbCrLf and the underscore ( _ ):
to COMPOSE a single line over several lines of code.

Confusing ? You betcha.

Also, you're inverting the order of the VbCrLf and the underscore,
which is why the sample is blowing up on you.

i.e., you have :

objMM.Body = DateTime.Now + " HI " & _
"<html>" & vbCrLf & vbCrLf & _
"<head>" & vbCrLf & vbCrLf & _
"</head>"& vbCrLf & vbCrLf & _
"<body>" & vbCrLf & vbCrLf & _

etc....

When what you should have is :

objMM.Body = DateTime.Now + " HI " _
& "<html>" & vbCrLf & vbCrLf _
& "<head>" & vbCrLf & vbCrLf _
& "</head>"& vbCrLf & vbCrLf _
& "<body>" & vbCrLf & vbCrLf _
etc...

i.e., the underscore goes at the end of the line
you want to break, BEFORE the ampersand on the next line.

Even more confusing is adding unneeded HTML tags to an HTML body
which doesn't need them, unless you need to have a background color.

Here's a version of the ASP101 sample without the
unneeded HTML tags and *with* HTML format :

<%@ Page Language="VB" ClientTarget="downlevel" %>
<%@ Import Namespace="System.Web.Mail" %>
<script language="VB" runat="server">
Sub btnSendMail_OnClick(Source As Object, E As EventArgs)
Dim myMessage As New MailMessage
Dim myMail As SmtpMail
Dim strEmail As String

If Page.IsValid() Then
strEmail = txtEmail.Text

myMessage.From = "admin@" & Request.ServerVariables("SERVER_NAME")
myMessage.To = strEmail
myMessage.Subject = "E-mail Sample (HTML)"

' This is the magic line. Without this the message will just appear
' as plain HTML and won't be rendered by the recipient's email client.
' It'd be as if they did "View Source" on a web page.
MyMessage.BodyFormat = MailFormat.Html

' This is multi-lined simply for readability.
' Notice that it is a properly formatted HTML
' message and not just plain text like most email.
' A lot of people have asked how to use form data
' in the emails so I added an example of including
' the entered address in the body of the email.
myMessage.Body = "<h2>Sample Message</h2>" & vbCrLf _
& " <p>" & vbCrLf _
& " This message was sent from a sample at" & vbCrLf _
& " <a href=""http://yourserver.com"">Your Server 101</a>." & vbCrLf _
& " It is used to show people how to send HTML" & vbCrLf _
& " formatted email from an ASP.NET page." & vbCrLf _
& " If you did not request this email yourself," & vbCrLf _
& " your address was entered by one of our" & vbCrLf _
& " visitors." & vbCrLf _
& " <strong>" & vbCrLf _
& " We do not store these e-mail addresses." & vbCrLf _
& " </strong>" & vbCrLf _
& " </p>" & vbCrLf _
& " <p><font size=""-1"">Please address all concerns to ad***@yourserver.com.</font></p>" &
vbCrLf _
& " <p><font size=""-1"">This message was sent to: " & strEmail & "</font></p>"

' Doesn't have to be local... just enter your
' SMTP server's name or ip address!
myMail.SmtpServer = "YourSMTPServer"
myMail.Send(myMessage)

frmEmail.Visible = False
lblUserMessage.Text = "An HTML-formatted email message has been sent to " & strEmail & "."
End If
End Sub
</script>

<html>
<head>
<title>ASP.NET Email (HTML Format) Sample</title>
</head>
<body>

<asp:Label id="lblUserMessage" text="Enter your e-mail address:" runat="server" />
<form method="post" id="frmEmail" runat="server">
<asp:TextBox id="txtEmail" size="30" runat="server" />
<asp:RequiredFieldValidator runat="server"
id="validEmailRequired" ControlToValidate="txtEmail"
errormessage="Please enter an email address."
display="Dynamic" />
<asp:RegularExpressionValidator runat="server"
id="validEmailRegExp" ControlToValidate="txtEmail"
ValidationExpression="^[\w-]+@[\w-]+\.(com|net|org|edu|mil)$"
errormessage="Please enter a valid email address."
Display="Dynamic" />

<asp:Button id="btnSendMail" text="Send Mail!" OnClick="btnSendMail_OnClick" runat="server" />
</form>

<hr />

</body>
</html>

------------------

You'll see that it compiles just fine and sends perfectly formatted HTML
without the need for those extra HTML tags ( <html>, <head>, <body<meta...>.

Of course, if you want the yellow background, or any other color,
or a background image, include the HTML tags.

I, personally, hate email sent to me as it's too gaudy, but to each his own.

Make sure you substitute your SMTP server's name before running the page:

myMail.SmtpServer = "YourSMTPServer"


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"dancer" <da****@microsoft.comwrote in message news:u9**************@TK2MSFTNGP05.phx.gbl...
Also, David,
I had asked why do I get this error message:
Compiler Error Message: BC30452: Operator '&' is not defined for types String' and
'System.Web.UI.WebControls.TextBox'.

A part of Juan's reply was Something else : you *must* put all the HTML content in ONE line.

Do you have any thoughts on that error message?
"David" <da*****************@revilloc.REMOVETHIS.comwrot e in message
news:ux**************@TK2MSFTNGP03.phx.gbl...
>Ah,

Sorry, I have my newsreader on to ignore read messages.

The P tags break the lines in the rendered page. BR tags also break lines (work as a hard wrap).

vbCrLf is a Visual Basic Carriage Return Line Feed. All this does is allow the source html wrap
onto a new line, so that your line is not too long.

If you want to use the same thing in C#, then it is something like...

email.Body = "This is my email body\nNow I am on a new line\nNote the backslash and n to create a
new line\n. I can't remember though, you might need \r\n to create a new line";

backslash n.

Is that what you looking for? This however doesn't affect your rendered output. use \n where
there is vbcrlf, however, vbcrlf is a defined constant, and \n has to be in quotes.

What you could do though is...

string vbCrLf = "\n";

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"dancer" <da****@microsoft.comwrote in message news:u3**************@TK2MSFTNGP04.phx.gbl...
>>David,

Not exactly does this answer my question. Could you please check out Juan's answer to my first
post on this subject and help me understand, since I was copying my code from this code.

Thank you.
"David" <da*****************@revilloc.REMOVETHIS.comwrot e in message
news:%2****************@TK2MSFTNGP02.phx.gbl.. .
The vbCrLf are purely to ensure that the line is not too long when generated. There is a
problem with over long lines that when they do eventually wrap, it can disrupt your formatted
email.

You will note that there are no br tags, but there are p tags <pand </p>. These are what
cause <P>aragraph breaks. (Actually, they are for new paragraphs rather than breaking
paragraphs).

Does this answer your question?

(Note, you probably can't press "Yes" below as you probably can't see it. If you can, then you
have better eyes than me, as I can't see it. :-)

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available

"dancer" <da****@microsoft.comwrote in message news:uH**************@TK2MSFTNGP04.phx.gbl...
Hi Juan,
>
What is the difference in what I am trying to do and this? Why can THEY break up the HTML
content into different lines?
>
email_html.aspx
--------------------------------------------------------------------------------
>
<%@ Page Language="VB" ClientTarget="downlevel" %>
<%@ Import Namespace="System.Web.Mail" %>
<script language="VB" runat="server">
Sub btnSendMail_OnClick(Source As Object, E As EventArgs)
Dim myMessage As New MailMessage
Dim myMail As SmtpMail
Dim strEmail As String
>
If Page.IsValid() Then
strEmail = txtEmail.Text
>
'myMessage.From = "webmaster@" & Request.ServerVariables("SERVER_NAME")
myMessage.From = "we*******@asp101.com"
myMessage.To = strEmail
myMessage.Subject = "E-mail Sample (HTML) from ASP 101!"
>
' This is the magic line. Without this the message will just appear
' as plain HTML and won't be rendered by the recipient's email client.
' It'd be as if they did "View Source" on a web page.
MyMessage.BodyFormat = MailFormat.Html
>
' This is multi-lined simply for readability.
' Notice that it is a properly formatted HTML
' message and not just plain text like most email.
' A lot of people have asked how to use form data
' in the emails so I added an example of including
' the entered address in the body of the email.
myMessage.Body = "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">" &
vbCrLf _
& "<html>" & vbCrLf _
& "<head>" & vbCrLf _
& " <title>Sample Message From ASP 101</title>" & vbCrLf _
& " <meta http-equiv=Content-Type content=""text/html; charset=iso-8859-1"">" & vbCrLf _
& "</head>" & vbCrLf _
& "<body bgcolor=""#FFFFCC"">" & vbCrLf _
& " <h2>Sample Message From ASP 101</h2>" & vbCrLf _
& " <p>" & vbCrLf _
& " This message was sent from a sample at" & vbCrLf _
& " <a href=""http://www.asp101.com"">ASP 101</a>." & vbCrLf _
& " It is used to show people how to send HTML" & vbCrLf _
& " formatted email from an ASP.NET page." & vbCrLf _
& " If you did not request this email yourself," & vbCrLf _
& " your address was entered by one of our" & vbCrLf _
& " visitors." & vbCrLf _
& " <strong>" & vbCrLf _
& " We do not store these e-mail addresses." & vbCrLf _
& " </strong>" & vbCrLf _
& " </p>" & vbCrLf _
& " <p><font size=""-1"">Please address all concerns to we*******@asp101.com.</font></p>" &
vbCrLf _
& " <p><font size=""-1"">This message was sent to: " & strEmail & "</font></p>" & vbCrLf _
& "</body>" & vbCrLf _
& "</html>" & vbCrLf
>
' Doesn't have to be local... just enter your
' SMTP server's name or ip address!
myMail.SmtpServer = "localhost"
myMail.Send(myMessage)
>
frmEmail.Visible = False
lblUserMessage.Text = "An HTML-formatted email message has been sent to " & strEmail & "."
End If
End Sub
</script>
>
<html>
<head>
<title>ASP.NET Email (HTML Format) Sample</title>
</head>
<body>
>
<asp:Label id="lblUserMessage" text="Enter your e-mail address:" runat="server" />
<form method="post" id="frmEmail" runat="server">
<asp:TextBox id="txtEmail" size="30" runat="server" />
<asp:RequiredFieldValidator runat="server"
id="validEmailRequired" ControlToValidate="txtEmail"
errormessage="Please enter an email address."
display="Dynamic" />
<asp:RegularExpressionValidator runat="server"
id="validEmailRegExp" ControlToValidate="txtEmail"
ValidationExpression="^[\w-]+@[\w-]+\.(com|net|org|edu|mil)$"
errormessage="Please enter a valid email address."
Display="Dynamic" />
>
<asp:Button id="btnSendMail" text="Send Mail!" OnClick="btnSendMail_OnClick" runat="server" />
</form>
>
<hr />
>
<p>
Click <a href="http://www.asp101.com/samples/email_html_aspx.asp">here</ato read about and
download the source code.
</p>
>
</body>
</html>
>
>
--------------------------------------------------------------------------------
>
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl.. .
>You don't need to set the html/head/body tags within the HTML body
>...and, in the VbCrLf thread, we established that you can't use VbCrLf in HTML.
>>
>Something else : you *must* put all the HTML content in ONE line.
>You can't break the lines with code.
>>
>Get rid of all the "VbCrLf" and all the "&" and write all your HTML in a single line,
>line-breaking the body's content with "<br />" or "<P... </P>" as needed.
>>
>Also, you can't insert Textbox controls into your HTML.
>>
>So, Check1.Text is out, too.
>>
>If you want to reference their content, after a user fills them out,
>capture it to a variable and use that, before writing to the body.
>>
>insert :
>>
>Dim Check1 as String = Check1.Text
>Dim Check2 as String = Check2.Text
>Dim Location as String = Location.Text
>before "Dim objMM as New MailMessage()"
>>
>and, when composing the body, use :
>>
>mail.Body="Hi, <p>The location where the accident occurred is :" & Location & "<br/>" &
>Check1 & "."
>' etc.
>>
>You *can* use the & to reference text variables.
>Notice the location of the quote marks.
>>
>>
>>
>>
>>
>Juan T. Llibre, asp.net MVP
>asp.net faq : http://asp.net.do/faq/
>foros de asp.net, en español : http://asp.net.do/foros/
>===================================
>"dancer" <da****@microsoft.comwrote in message news:uU*************@TK2MSFTNGP05.phx.gbl...
>>Can somebody tell me why I get this message with the following code?
>>>
>>Compiler Error Message: BC30452: Operator '&' is not defined for types 'String' and
>>'System.Web.UI.WebControls.TextBox'.
>>>
>><html>
>>>
>><head>
>>>
>><% @Import Namespace="System.Web.Mail" %>
>>>
>><script language="VB" runat="server">
>>>
>>>
>>>
>>Sub btnSendFeedback_Click(sender as Object, e as EventArgs)
>>>
>>'Create an instance of the MailMessage class
>>>
>>Dim objMM as New MailMessage()
>>>
>>'Set the properties - send the email to the person who filled out the
>>>
>>'feedback form.
>>>
>>objMM.To = "xx*****@xxxxxxx.com"
>>>
>>>
>>objMM.From = "xx*****@xxxxxxx.com"
>>>
>>'send in html format
>>>
>>objMM.BodyFormat = MailFormat.html
>>>
>>'Set the priority - options are High, Low, and Normal
>>>
>>objMM.Priority = MailPriority.Normal
>>>
>>'Set the subject
>>>
>>objMM.Subject = "Accident Investigation Form"
>>>
>>>
>>'Set the body
>>>
>>objMM.Body = DateTime.Now + " HI " & _
>>>
>>"<html>" & vbCrLf & vbCrLf & _
>>>
>>"<head>" & vbCrLf & vbCrLf & _
>>>
>>"</head>"& vbCrLf & vbCrLf & _
>>>
>>"<body>" & vbCrLf & vbCrLf & _
>>>
>>Location where accident occurred:
>>>
>>Location.Text & _
>>>
>>"<br>"& _
>>>
>7Check1.Text & "." & vbCrLf & vbCrLf & _
>>>
>>vbCrLf &vbCrLf & _
>>>
>>Check2.Text & vbCrLf & _
>>>
>>"</td>" & vbCrLf & vbCrLf & _
>>>
>>"</body>" & vbCrLf & vbCrLf & _
>>>
>>"</html>"
>>>
>>>
>>'Specify to use the default Smtp Server
>>>
>>SmtpMail.SmtpServer = ""
>>>
>>'Now, to send the message, use the Send method of the SmtpMail class
>>>
>>SmtpMail.Send(objMM)
>>>
>>panelSendEmail.Visible = false
>>>
>>panelMailSent.Visible = true
>>>
>>End Sub
>>>
>>>
>>>
>></script>
>>>
>></head>
>>>
>>>
>><body>
>>>
>><table width="750" bgcolor="#E9EDF4" table border="1" cellpadding="3">
>>>
>><h3><center><font face="Verdana">Wheeler's Accident Investigation Form</font></h3>
>>>
>>>
>>>
>><hr>
>>>
>><%--__________________________________________________ __________________________--%>
>>>
>><%--ROW 1--%>
>>>
>>>
>><td width="250" valign="top">
>>>
>>>
>><form runat="server">
>>>
>><font face="Verdana" Size="2">
>>>
>>Location where accident occurred: <asp:textbox id="Location" runat=server Width="200"/>
>>>
>></td>
>>>
>><td align="right" valign="top" width="225">
>>>
>>>
>><font face="Verdana" Size="2">Employer's Premises
>>>
>>>
>>>
>><asp:CheckBox id=Check1 Text="yes" runat="server" />
>>>
>><asp:CheckBox id=Check2 Text="no" runat="server" />
>>>
>><br>
>>>
>>>
>>Job site
>>>
>><asp:CheckBox id=Check3 Text="yes" runat="server" />
>>>
>><asp:CheckBox id=Check4 Text="no" runat="server" />
>>>
>>>
>></td>
>>>
>><td>
>>>
>><font face="Verdana" Size="2">Date of accident</font><br>
>>>
>><asp:textbox id="Date" runat=server Width="100"/>
>>>
>>>
>></td>
>>>
>><%--__________________________________________________ __________________________--%>
>>>
>><%--ROW 2--%>
>>>
>>>
>><tr<td>
>>>
>><font face="Verdana" Size="2">Who was injured?</font><br>
>>>
>><asp:textbox id="Who" runat=server width="200"/>
>>>
>></td>
>>>
>><td align= "left">
>>>
>><font face="Verdana" Size="2">Employee <asp:CheckBox id=Check5 runat="server" />
>>>
>><br>
>>>
>>Non-employee <asp:CheckBox id=Check6 runat="server" />
>>>
>>>
>></td>
>>>
>><td align="right"><font face="Verdana" Size="2">
>>>
>>Time of accident a.m. <asp:textbox id="am" runat=server Width="90"/>
>>>
>>p.m. <asp:textbox id="pm" runat=server Width="90"/>
>>>
>></TD>
>>>
>><%--__________________________________________________ __________________________--%>
>>>
>><%--ROW 3--%>
>>>
>><tr>
>>>
>><td>
>>>
>><font face="Verdana" Size="2">Date of Hire <br<asp:textbox id="Hiredate" runat=server/>
>>>
>></td>
>>>
>><td>
>>>
>><font face="Verdana" Size="2">Job Title or Occupation <br><asp:textbox id="occupation"
>>runat=server width="200"/>
>>>
>></td>
>>>
>><td>
>>>
>><font face="Verdana" Size="2">How long has employee worked at job where injury
>>occurred?<br><asp:textbox id="lengthofjob" runat=server/>
>>>
>></td>
>>>
>><%--__________________________________________________ __________________________--%>
>>>
>><%--Row 4--%>
>>>
>>&nbsp&nbsp
>>>
>>>
>>>
>><p>
>>>
>>>
>><asp:Label id=Label1 font-name="arial" font-size="10pt" runat="server"/>
>>>
>><!Copied from /smirnof>
>>>
>><asp:panel id="panelSendEmail" runat="server">
>>>
>>>
>>>
>>>
>>>
>><%--asp:textbox id= runat="server" /--%>
>>>
>><br>
>>>
>><b>Your Message:</b><br>
>>>
>><%--asp:textbox id="txtMessage" TextMode="MultiLine"
>>>
>>Columns="40" Rows="10" runat="server" /--%>
>>>
>><p>
>>>
>>>
>>>
>><asp:button runat="server" id="btnSendFeedback" Text="Send
>>>
>>Feedback!"
>>>
>>OnClick="btnSendFeedback_Click" />
>>>
>>>
>>>
>></asp:panel>
>>>
>><asp:panel id="panelMailSent" runat="server" Visible="False">
>>>
>>An email has been sent to the email address you specified.
>>>
>>Thanks!
>>>
>></asp:panel>
>>>
>></form>
>>>
>></body>
>>>
>></html>
>>>
>>>
>>
>>
>
>
>




May 10 '07 #18

P: n/a
Thank you, Juan. I will try again.
You said, "I, personally, hate email sent to me as it's too gaudy, but to
each his own."
I assume you mean you hate HTML email. The reason I want HTML email is so
that the Safety Director can see what the supervisor entered in the online
investigation report in the SAME FORMAT as the supervisor saw it.
Perhaps you have a better idea for returning the information to the Safety
Director?
I would love another option.

"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:uq**************@TK2MSFTNGP02.phx.gbl...
re:
!A part of Juan's reply was Something else : you *must* put all the HTML
!content in ONE line.

I meant : "all the HTML content in ONE line".

The sample at ASP101 places all the HTML content in ONE line,
even though it composes that single line in several lines.

That's why you need to use VbCrLf and the underscore ( _ ):
to COMPOSE a single line over several lines of code.

Confusing ? You betcha.

Also, you're inverting the order of the VbCrLf and the underscore,
which is why the sample is blowing up on you.

i.e., you have :

objMM.Body = DateTime.Now + " HI " & _
"<html>" & vbCrLf & vbCrLf & _
"<head>" & vbCrLf & vbCrLf & _
"</head>"& vbCrLf & vbCrLf & _
"<body>" & vbCrLf & vbCrLf & _

etc....

When what you should have is :

objMM.Body = DateTime.Now + " HI " _
& "<html>" & vbCrLf & vbCrLf _
& "<head>" & vbCrLf & vbCrLf _
& "</head>"& vbCrLf & vbCrLf _
& "<body>" & vbCrLf & vbCrLf _
etc...

i.e., the underscore goes at the end of the line
you want to break, BEFORE the ampersand on the next line.

Even more confusing is adding unneeded HTML tags to an HTML body
which doesn't need them, unless you need to have a background color.

Here's a version of the ASP101 sample without the
unneeded HTML tags and *with* HTML format :

<%@ Page Language="VB" ClientTarget="downlevel" %>
<%@ Import Namespace="System.Web.Mail" %>
<script language="VB" runat="server">
Sub btnSendMail_OnClick(Source As Object, E As EventArgs)
Dim myMessage As New MailMessage
Dim myMail As SmtpMail
Dim strEmail As String

If Page.IsValid() Then
strEmail = txtEmail.Text

myMessage.From = "admin@" & Request.ServerVariables("SERVER_NAME")
myMessage.To = strEmail
myMessage.Subject = "E-mail Sample (HTML)"

' This is the magic line. Without this the message will just appear
' as plain HTML and won't be rendered by the recipient's email client.
' It'd be as if they did "View Source" on a web page.
MyMessage.BodyFormat = MailFormat.Html

' This is multi-lined simply for readability.
' Notice that it is a properly formatted HTML
' message and not just plain text like most email.
' A lot of people have asked how to use form data
' in the emails so I added an example of including
' the entered address in the body of the email.
myMessage.Body = "<h2>Sample Message</h2>" & vbCrLf _
& " <p>" & vbCrLf _
& " This message was sent from a sample at" & vbCrLf _
& " <a href=""http://yourserver.com"">Your Server 101</a>." & vbCrLf _
& " It is used to show people how to send HTML" & vbCrLf _
& " formatted email from an ASP.NET page." & vbCrLf _
& " If you did not request this email yourself," & vbCrLf _
& " your address was entered by one of our" & vbCrLf _
& " visitors." & vbCrLf _
& " <strong>" & vbCrLf _
& " We do not store these e-mail addresses." & vbCrLf _
& " </strong>" & vbCrLf _
& " </p>" & vbCrLf _
& " <p><font size=""-1"">Please address all concerns to
ad***@yourserver.com.</font></p>" & vbCrLf _
& " <p><font size=""-1"">This message was sent to: " & strEmail &
"</font></p>"

' Doesn't have to be local... just enter your
' SMTP server's name or ip address!
myMail.SmtpServer = "YourSMTPServer"
myMail.Send(myMessage)

frmEmail.Visible = False
lblUserMessage.Text = "An HTML-formatted email message has been sent to
" & strEmail & "."
End If
End Sub
</script>

<html>
<head>
<title>ASP.NET Email (HTML Format) Sample</title>
</head>
<body>

<asp:Label id="lblUserMessage" text="Enter your e-mail address:"
runat="server" />
<form method="post" id="frmEmail" runat="server">
<asp:TextBox id="txtEmail" size="30" runat="server" />
<asp:RequiredFieldValidator runat="server"
id="validEmailRequired" ControlToValidate="txtEmail"
errormessage="Please enter an email address."
display="Dynamic" />
<asp:RegularExpressionValidator runat="server"
id="validEmailRegExp" ControlToValidate="txtEmail"
ValidationExpression="^[\w-]+@[\w-]+\.(com|net|org|edu|mil)$"
errormessage="Please enter a valid email address."
Display="Dynamic" />

<asp:Button id="btnSendMail" text="Send Mail!"
OnClick="btnSendMail_OnClick" runat="server" />
</form>

<hr />

</body>
</html>

------------------

You'll see that it compiles just fine and sends perfectly formatted HTML
without the need for those extra HTML tags ( <html>, <head>, <body>
<meta...>.

Of course, if you want the yellow background, or any other color,
or a background image, include the HTML tags.

I, personally, hate email sent to me as it's too gaudy, but to each his
own.

Make sure you substitute your SMTP server's name before running the page:

myMail.SmtpServer = "YourSMTPServer"


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"dancer" <da****@microsoft.comwrote in message
news:u9**************@TK2MSFTNGP05.phx.gbl...
>Also, David,
I had asked why do I get this error message:
Compiler Error Message: BC30452: Operator '&' is not defined for types
String' and 'System.Web.UI.WebControls.TextBox'.

A part of Juan's reply was Something else : you *must* put all the HTML
content in ONE line.

Do you have any thoughts on that error message?
"David" <da*****************@revilloc.REMOVETHIS.comwrot e in message
news:ux**************@TK2MSFTNGP03.phx.gbl...
>>Ah,

Sorry, I have my newsreader on to ignore read messages.

The P tags break the lines in the rendered page. BR tags also break
lines (work as a hard wrap).

vbCrLf is a Visual Basic Carriage Return Line Feed. All this does is
allow the source html wrap onto a new line, so that your line is not too
long.

If you want to use the same thing in C#, then it is something like...

email.Body = "This is my email body\nNow I am on a new line\nNote the
backslash and n to create a new line\n. I can't remember though, you
might need \r\n to create a new line";

backslash n.

Is that what you looking for? This however doesn't affect your rendered
output. use \n where there is vbcrlf, however, vbcrlf is a defined
constant, and \n has to be in quotes.

What you could do though is...

string vbCrLf = "\n";

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"dancer" <da****@microsoft.comwrote in message
news:u3**************@TK2MSFTNGP04.phx.gbl...
David,

Not exactly does this answer my question. Could you please check out
Juan's answer to my first post on this subject and help me understand,
since I was copying my code from this code.

Thank you.
"David" <da*****************@revilloc.REMOVETHIS.comwrot e in message
news:%2****************@TK2MSFTNGP02.phx.gbl. ..
The vbCrLf are purely to ensure that the line is not too long when
generated. There is a problem with over long lines that when they do
eventually wrap, it can disrupt your formatted email.
>
You will note that there are no br tags, but there are p tags <pand
</p>. These are what cause <P>aragraph breaks. (Actually, they are for
new paragraphs rather than breaking paragraphs).
>
Does this answer your question?
>
(Note, you probably can't press "Yes" below as you probably can't see
it. If you can, then you have better eyes than me, as I can't see it.
:-)
>
--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
>
"dancer" <da****@microsoft.comwrote in message
news:uH**************@TK2MSFTNGP04.phx.gbl.. .
>Hi Juan,
>>
>What is the difference in what I am trying to do and this? Why can
>THEY break up the HTML content into different lines?
>>
>email_html.aspx
>--------------------------------------------------------------------------------
>>
><%@ Page Language="VB" ClientTarget="downlevel" %>
><%@ Import Namespace="System.Web.Mail" %>
><script language="VB" runat="server">
>Sub btnSendMail_OnClick(Source As Object, E As EventArgs)
>Dim myMessage As New MailMessage
>Dim myMail As SmtpMail
>Dim strEmail As String
>>
>If Page.IsValid() Then
>strEmail = txtEmail.Text
>>
>'myMessage.From = "webmaster@" &
>Request.ServerVariables("SERVER_NAME")
>myMessage.From = "we*******@asp101.com"
>myMessage.To = strEmail
>myMessage.Subject = "E-mail Sample (HTML) from ASP 101!"
>>
>' This is the magic line. Without this the message will just appear
>' as plain HTML and won't be rendered by the recipient's email
>client.
>' It'd be as if they did "View Source" on a web page.
>MyMessage.BodyFormat = MailFormat.Html
>>
>' This is multi-lined simply for readability.
>' Notice that it is a properly formatted HTML
>' message and not just plain text like most email.
>' A lot of people have asked how to use form data
>' in the emails so I added an example of including
>' the entered address in the body of the email.
>myMessage.Body = "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0
>Transitional//EN"">" & vbCrLf _
>& "<html>" & vbCrLf _
>& "<head>" & vbCrLf _
>& " <title>Sample Message From ASP 101</title>" & vbCrLf _
>& " <meta http-equiv=Content-Type content=""text/html;
>charset=iso-8859-1"">" & vbCrLf _
>& "</head>" & vbCrLf _
>& "<body bgcolor=""#FFFFCC"">" & vbCrLf _
>& " <h2>Sample Message From ASP 101</h2>" & vbCrLf _
>& " <p>" & vbCrLf _
>& " This message was sent from a sample at" & vbCrLf _
>& " <a href=""http://www.asp101.com"">ASP 101</a>." & vbCrLf _
>& " It is used to show people how to send HTML" & vbCrLf _
>& " formatted email from an ASP.NET page." & vbCrLf _
>& " If you did not request this email yourself," & vbCrLf _
>& " your address was entered by one of our" & vbCrLf _
>& " visitors." & vbCrLf _
>& " <strong>" & vbCrLf _
>& " We do not store these e-mail addresses." & vbCrLf _
>& " </strong>" & vbCrLf _
>& " </p>" & vbCrLf _
>& " <p><font size=""-1"">Please address all concerns to
>we*******@asp101.com.</font></p>" & vbCrLf _
>& " <p><font size=""-1"">This message was sent to: " & strEmail &
>"</font></p>" & vbCrLf _
>& "</body>" & vbCrLf _
>& "</html>" & vbCrLf
>>
>' Doesn't have to be local... just enter your
>' SMTP server's name or ip address!
>myMail.SmtpServer = "localhost"
>myMail.Send(myMessage)
>>
>frmEmail.Visible = False
>lblUserMessage.Text = "An HTML-formatted email message has been sent
>to " & strEmail & "."
>End If
>End Sub
></script>
>>
><html>
><head>
><title>ASP.NET Email (HTML Format) Sample</title>
></head>
><body>
>>
><asp:Label id="lblUserMessage" text="Enter your e-mail address:"
>runat="server" />
><form method="post" id="frmEmail" runat="server">
><asp:TextBox id="txtEmail" size="30" runat="server" />
><asp:RequiredFieldValidator runat="server"
>id="validEmailRequired" ControlToValidate="txtEmail"
>errormessage="Please enter an email address."
>display="Dynamic" />
><asp:RegularExpressionValidator runat="server"
>id="validEmailRegExp" ControlToValidate="txtEmail"
>ValidationExpression="^[\w-]+@[\w-]+\.(com|net|org|edu|mil)$"
>errormessage="Please enter a valid email address."
>Display="Dynamic" />
>>
><asp:Button id="btnSendMail" text="Send Mail!"
>OnClick="btnSendMail_OnClick" runat="server" />
></form>
>>
><hr />
>>
><p>
>Click <a
>href="http://www.asp101.com/samples/email_html_aspx.asp">here</ato
>read about and download the source code.
></p>
>>
></body>
></html>
>>
>>
>--------------------------------------------------------------------------------
>>
>"Juan T. Llibre" <no***********@nowhere.comwrote in message
>news:%2****************@TK2MSFTNGP02.phx.gbl. ..
>>You don't need to set the html/head/body tags within the HTML body
>>...and, in the VbCrLf thread, we established that you can't use
>>VbCrLf in HTML.
>>>
>>Something else : you *must* put all the HTML content in ONE line.
>>You can't break the lines with code.
>>>
>>Get rid of all the "VbCrLf" and all the "&" and write all your HTML
>>in a single line,
>>line-breaking the body's content with "<br />" or "<P... </P>" as
>>needed.
>>>
>>Also, you can't insert Textbox controls into your HTML.
>>>
>>So, Check1.Text is out, too.
>>>
>>If you want to reference their content, after a user fills them out,
>>capture it to a variable and use that, before writing to the body.
>>>
>>insert :
>>>
>>Dim Check1 as String = Check1.Text
>>Dim Check2 as String = Check2.Text
>>Dim Location as String = Location.Text
>>before "Dim objMM as New MailMessage()"
>>>
>>and, when composing the body, use :
>>>
>>mail.Body="Hi, <p>The location where the accident occurred is :" &
>>Location & "<br/>" & Check1 & "."
>>' etc.
>>>
>>You *can* use the & to reference text variables.
>>Notice the location of the quote marks.
>>>
>>>
>>>
>>>
>>>
>>Juan T. Llibre, asp.net MVP
>>asp.net faq : http://asp.net.do/faq/
>>foros de asp.net, en español : http://asp.net.do/foros/
>>===================================
>>"dancer" <da****@microsoft.comwrote in message
>>news:uU*************@TK2MSFTNGP05.phx.gbl. ..
>>>Can somebody tell me why I get this message with the following
>>>code?
>>>>
>>>Compiler Error Message: BC30452: Operator '&' is not defined for
>>>types 'String' and
>>>'System.Web.UI.WebControls.TextBox'.
>>>>
>>><html>
>>>>
>>><head>
>>>>
>>><% @Import Namespace="System.Web.Mail" %>
>>>>
>>><script language="VB" runat="server">
>>>>
>>>>
>>>>
>>>Sub btnSendFeedback_Click(sender as Object, e as EventArgs)
>>>>
>>>'Create an instance of the MailMessage class
>>>>
>>>Dim objMM as New MailMessage()
>>>>
>>>'Set the properties - send the email to the person who filled out
>>>the
>>>>
>>>'feedback form.
>>>>
>>>objMM.To = "xx*****@xxxxxxx.com"
>>>>
>>>>
>>>objMM.From = "xx*****@xxxxxxx.com"
>>>>
>>>'send in html format
>>>>
>>>objMM.BodyFormat = MailFormat.html
>>>>
>>>'Set the priority - options are High, Low, and Normal
>>>>
>>>objMM.Priority = MailPriority.Normal
>>>>
>>>'Set the subject
>>>>
>>>objMM.Subject = "Accident Investigation Form"
>>>>
>>>>
>>>'Set the body
>>>>
>>>objMM.Body = DateTime.Now + " HI " & _
>>>>
>>>"<html>" & vbCrLf & vbCrLf & _
>>>>
>>>"<head>" & vbCrLf & vbCrLf & _
>>>>
>>>"</head>"& vbCrLf & vbCrLf & _
>>>>
>>>"<body>" & vbCrLf & vbCrLf & _
>>>>
>>>Location where accident occurred:
>>>>
>>>Location.Text & _
>>>>
>>>"<br>"& _
>>>>
>>7Check1.Text & "." & vbCrLf & vbCrLf & _
>>>>
>>>vbCrLf &vbCrLf & _
>>>>
>>>Check2.Text & vbCrLf & _
>>>>
>>>"</td>" & vbCrLf & vbCrLf & _
>>>>
>>>"</body>" & vbCrLf & vbCrLf & _
>>>>
>>>"</html>"
>>>>
>>>>
>>>'Specify to use the default Smtp Server
>>>>
>>>SmtpMail.SmtpServer = ""
>>>>
>>>'Now, to send the message, use the Send method of the SmtpMail
>>>class
>>>>
>>>SmtpMail.Send(objMM)
>>>>
>>>panelSendEmail.Visible = false
>>>>
>>>panelMailSent.Visible = true
>>>>
>>>End Sub
>>>>
>>>>
>>>>
>>></script>
>>>>
>>></head>
>>>>
>>>>
>>><body>
>>>>
>>><table width="750" bgcolor="#E9EDF4" table border="1"
>>>cellpadding="3">
>>>>
>>><h3><center><font face="Verdana">Wheeler's Accident Investigation
>>>Form</font></h3>
>>>>
>>>>
>>>>
>>><hr>
>>>>
>>><%--__________________________________________________ __________________________--%>
>>>>
>>><%--ROW 1--%>
>>>>
>>>>
>>><td width="250" valign="top">
>>>>
>>>>
>>><form runat="server">
>>>>
>>><font face="Verdana" Size="2">
>>>>
>>>Location where accident occurred: <asp:textbox id="Location"
>>>runat=server Width="200"/>
>>>>
>>></td>
>>>>
>>><td align="right" valign="top" width="225">
>>>>
>>>>
>>><font face="Verdana" Size="2">Employer's Premises
>>>>
>>>>
>>>>
>>><asp:CheckBox id=Check1 Text="yes" runat="server" />
>>>>
>>><asp:CheckBox id=Check2 Text="no" runat="server" />
>>>>
>>><br>
>>>>
>>>>
>>>Job site
>>>>
>>><asp:CheckBox id=Check3 Text="yes" runat="server" />
>>>>
>>><asp:CheckBox id=Check4 Text="no" runat="server" />
>>>>
>>>>
>>></td>
>>>>
>>><td>
>>>>
>>><font face="Verdana" Size="2">Date of accident</font><br>
>>>>
>>><asp:textbox id="Date" runat=server Width="100"/>
>>>>
>>>>
>>></td>
>>>>
>>><%--__________________________________________________ __________________________--%>
>>>>
>>><%--ROW 2--%>
>>>>
>>>>
>>><tr<td>
>>>>
>>><font face="Verdana" Size="2">Who was injured?</font><br>
>>>>
>>><asp:textbox id="Who" runat=server width="200"/>
>>>>
>>></td>
>>>>
>>><td align= "left">
>>>>
>>><font face="Verdana" Size="2">Employee <asp:CheckBox id=Check5
>>>runat="server" />
>>>>
>>><br>
>>>>
>>>Non-employee <asp:CheckBox id=Check6 runat="server" />
>>>>
>>>>
>>></td>
>>>>
>>><td align="right"><font face="Verdana" Size="2">
>>>>
>>>Time of accident a.m. <asp:textbox id="am" runat=server
>>>Width="90"/>
>>>>
>>>p.m. <asp:textbox id="pm" runat=server Width="90"/>
>>>>
>>></TD>
>>>>
>>><%--__________________________________________________ __________________________--%>
>>>>
>>><%--ROW 3--%>
>>>>
>>><tr>
>>>>
>>><td>
>>>>
>>><font face="Verdana" Size="2">Date of Hire <br<asp:textbox
>>>id="Hiredate" runat=server/>
>>>>
>>></td>
>>>>
>>><td>
>>>>
>>><font face="Verdana" Size="2">Job Title or Occupation
>>><br><asp:textbox id="occupation"
>>>runat=server width="200"/>
>>>>
>>></td>
>>>>
>>><td>
>>>>
>>><font face="Verdana" Size="2">How long has employee worked at job
>>>where injury
>>>occurred?<br><asp:textbox id="lengthofjob" runat=server/>
>>>>
>>></td>
>>>>
>>><%--__________________________________________________ __________________________--%>
>>>>
>>><%--Row 4--%>
>>>>
>>>&nbsp&nbsp
>>>>
>>>>
>>>>
>>><p>
>>>>
>>>>
>>><asp:Label id=Label1 font-name="arial" font-size="10pt"
>>>runat="server"/>
>>>>
>>><!Copied from /smirnof>
>>>>
>>><asp:panel id="panelSendEmail" runat="server">
>>>>
>>>>
>>>>
>>>>
>>>>
>>><%--asp:textbox id= runat="server" /--%>
>>>>
>>><br>
>>>>
>>><b>Your Message:</b><br>
>>>>
>>><%--asp:textbox id="txtMessage" TextMode="MultiLine"
>>>>
>>>Columns="40" Rows="10" runat="server" /--%>
>>>>
>>><p>
>>>>
>>>>
>>>>
>>><asp:button runat="server" id="btnSendFeedback" Text="Send
>>>>
>>>Feedback!"
>>>>
>>>OnClick="btnSendFeedback_Click" />
>>>>
>>>>
>>>>
>>></asp:panel>
>>>>
>>><asp:panel id="panelMailSent" runat="server" Visible="False">
>>>>
>>>An email has been sent to the email address you specified.
>>>>
>>>Thanks!
>>>>
>>></asp:panel>
>>>>
>>></form>
>>>>
>>></body>
>>>>
>>></html>
>>>>
>>>>
>>>
>>>
>>
>>
>>
>
>




May 10 '07 #19

P: n/a
"dancer" <da****@microsoft.comwrote in message
news:uV*************@TK2MSFTNGP02.phx.gbl...
You said, "I, personally, hate email sent to me as it's too gaudy, but to
each his own."
I assume you mean you hate HTML email.
More and more people have their email software configured not to display the
HTML content of email.

Some people even have their email software configured to automatically
reject HTML email.

Don't use it if you can avoid it...
--
http://www.markrae.net

May 10 '07 #20

P: n/a
re:
I assume you mean you hate HTML email.
Yes, I meant that, although I don't hate it for the HTML itself.
I hate it when background colors, garish font colors and many fonts are used.

re:
Perhaps you have a better idea for returning the information to the Safety Director?
My suggestion stands : get rid of the useless HTML tags and background color.

Business mail should be business-like in appearance.

You *can* send HTML mail with a white background, using a single standard font like Arial,
bolding the headlines and/or paragraph headings, using a larger font size for headlines,
and keeping the use of color to a minimum...or even not using it at all.

Your Safety Director will appreciate that in your business report, I'm sure.

I formatted this response as HTML to show you what the ASP101
sample looks like when formatted with business mail in mind:

-------------

Sample Message
This message was sent from a sample at ASP101.

It is used to show people how to send HTML formatted email from an ASP.NET page.
If you did not request this email yourself, your address was entered by one of our visitors.

We do not store these e-mail addresses

--------

Notice the difference...
Instead of the garish yellow background in the original sample, you have a clean, crisp, business format.

Good luck and, if you run into more problems, post back.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"dancer" <da****@microsoft.comwrote in message news:uV*************@TK2MSFTNGP02.phx.gbl...
Thank you, Juan. I will try again.
You said, "I, personally, hate email sent to me as it's too gaudy, but to
each his own."
I assume you mean you hate HTML email. The reason I want HTML email is so
that the Safety Director can see what the supervisor entered in the online
investigation report in the SAME FORMAT as the supervisor saw it.
Perhaps you have a better idea for returning the information to the Safety
Director?
I would love another option.

"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:uq**************@TK2MSFTNGP02.phx.gbl...
>re:
!A part of Juan's reply was Something else : you *must* put all the HTML
!content in ONE line.

I meant : "all the HTML content in ONE line".

The sample at ASP101 places all the HTML content in ONE line,
even though it composes that single line in several lines.

That's why you need to use VbCrLf and the underscore ( _ ):
to COMPOSE a single line over several lines of code.

Confusing ? You betcha.

Also, you're inverting the order of the VbCrLf and the underscore,
which is why the sample is blowing up on you.

i.e., you have :

objMM.Body = DateTime.Now + " HI " & _
"<html>" & vbCrLf & vbCrLf & _
"<head>" & vbCrLf & vbCrLf & _
"</head>"& vbCrLf & vbCrLf & _
"<body>" & vbCrLf & vbCrLf & _

etc....

When what you should have is :

objMM.Body = DateTime.Now + " HI " _
& "<html>" & vbCrLf & vbCrLf _
& "<head>" & vbCrLf & vbCrLf _
& "</head>"& vbCrLf & vbCrLf _
& "<body>" & vbCrLf & vbCrLf _
etc...

i.e., the underscore goes at the end of the line
you want to break, BEFORE the ampersand on the next line.
>Even more confusing is adding unneeded HTML tags to an HTML body
which doesn't need them, unless you need to have a background color.
May 10 '07 #21

P: n/a
Juan and Mark,

We are kindred spirits on the garish appearance. I hate even WEB SITES that are not designed with restraint and taste. And if there is EVER anything that moves or talks on a web site, I leave it immediately!
Obviously, I have not clearly stated my problem and my goal.
At the moment, supervisors are filling out a paper form by hand with a pen. That is delivered by truck mail to the safety director. It is then put in the employee's individual file. This will take the place of that.
Forms, as you know, have boxes, lines, directions, check boxes, large fonts, small fonts.
I do not need color. I just need it to look like a form, which is pretty much what the web page will look like.

Is there any other way to do that?

By the way, I have not seen the ASP101 in HTML, because the validation section won't accept my e-mail. My e-mail is in the format of firstname.lastname.@server.com. I notice the validation code seems to want only one name before the @server.com and I don't know how to change it. Could you help me with that?

Thank you
"Juan T. Llibre" <no***********@nowhere.comwrote in message news:OU**************@TK2MSFTNGP05.phx.gbl...
re:
I assume you mean you hate HTML email.
Yes, I meant that, although I don't hate it for the HTML itself.
I hate it when background colors, garish font colors and many fonts are used.

re:
Perhaps you have a better idea for returning the information to the Safety Director?
My suggestion stands : get rid of the useless HTML tags and background color.

Business mail should be business-like in appearance.

You *can* send HTML mail with a white background, using a single standard font like Arial,
bolding the headlines and/or paragraph headings, using a larger font size for headlines,
and keeping the use of color to a minimum...or even not using it at all.

Your Safety Director will appreciate that in your business report, I'm sure.

I formatted this response as HTML to show you what the ASP101
sample looks like when formatted with business mail in mind:

-------------

Sample Message
This message was sent from a sample at ASP101.

It is used to show people how to send HTML formatted email from an ASP.NET page.
If you did not request this email yourself, your address was entered by one of our visitors.

We do not store these e-mail addresses

--------

Notice the difference...
Instead of the garish yellow background in the original sample, you have a clean, crisp, business format.

Good luck and, if you run into more problems, post back.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"dancer" <da****@microsoft.comwrote in message news:uV*************@TK2MSFTNGP02.phx.gbl...
Thank you, Juan. I will try again.
You said, "I, personally, hate email sent to me as it's too gaudy, but to
each his own."
I assume you mean you hate HTML email. The reason I want HTML email is so
that the Safety Director can see what the supervisor entered in the online
investigation report in the SAME FORMAT as the supervisor saw it.
Perhaps you have a better idea for returning the information to the Safety
Director?
I would love another option.

"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:uq**************@TK2MSFTNGP02.phx.gbl...
>re:
!A part of Juan's reply was Something else : you *must* put all the HTML
!content in ONE line.

I meant : "all the HTML content in ONE line".

The sample at ASP101 places all the HTML content in ONE line,
even though it composes that single line in several lines.

That's why you need to use VbCrLf and the underscore ( _ ):
to COMPOSE a single line over several lines of code.

Confusing ? You betcha.

Also, you're inverting the order of the VbCrLf and the underscore,
which is why the sample is blowing up on you.

i.e., you have :

objMM.Body = DateTime.Now + " HI " & _
"<html>" & vbCrLf & vbCrLf & _
"<head>" & vbCrLf & vbCrLf & _
"</head>"& vbCrLf & vbCrLf & _
"<body>" & vbCrLf & vbCrLf & _

etc....

When what you should have is :

objMM.Body = DateTime.Now + " HI " _
& "<html>" & vbCrLf & vbCrLf _
& "<head>" & vbCrLf & vbCrLf _
& "</head>"& vbCrLf & vbCrLf _
& "<body>" & vbCrLf & vbCrLf _
etc...

i.e., the underscore goes at the end of the line
you want to break, BEFORE the ampersand on the next line.
>Even more confusing is adding unneeded HTML tags to an HTML body
which doesn't need them, unless you need to have a background color.
May 10 '07 #22

P: n/a
re:
!I just need it to look like a form, which is pretty much what the web page will look like.
!Is there any other way to do that?

No, there isn't. Use the HTML if you need it, and apparently you do.
Just don't go ga-ga on it.

:-)

re:
!I notice the validation code seems to want only one name before the
!@server.com and I don't know how to change it. Could you help me with that?

Sure. Just substitute this ValidationExpression for the one you have now:

ValidationExpression="^[\w-]+(\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$"

Copy and past the whole line, so there's no transcription mistakes.

That RegExp matches 99.99% of e-mail addresses.

The {2,7} at the end leaves space for top level domains
as short as .do but leaves room for longer ones like .info, .museum, etc.

It also matches :
fi****************@server.com
so*******@mail.server.com
ja*********@some.com ( Notice the underscore )
fo*@foo.ca
fo*@foo.server.ca
fo*@foo.co.uk
fo*@someserver.info
fo*****@someserver.museum
....and many other combinations.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"dancer" <da****@microsoft.comwrote in message news:eF**************@TK2MSFTNGP05.phx.gbl...
Juan and Mark,

We are kindred spirits on the garish appearance. I hate even WEB SITES that are not designed with
restraint and taste. And if there is EVER anything that moves or talks on a web site, I leave it
immediately!

Obviously, I have not clearly stated my problem and my goal.
At the moment, supervisors are filling out a paper form by hand with a pen. That is delivered by
truck mail to the safety director. It is then put in the employee's individual file. This will
take the place of that.

Forms, as you know, have boxes, lines, directions, check boxes, large fonts, small fonts.
I do not need color. I just need it to look like a form, which is pretty much what the web page
will look like.

Is there any other way to do that?

By the way, I have not seen the ASP101 in HTML, because the validation section won't accept my
e-mail. My e-mail is in the format of firstname.lastname.@server.com. I notice the validation code
seems to want only one name before the @server.com and I don't know how to change it. Could you
help me with that?

Thank you
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:OU**************@TK2MSFTNGP05.phx.gbl...
re:
I assume you mean you hate HTML email.
Yes, I meant that, although I don't hate it for the HTML itself.
I hate it when background colors, garish font colors and many fonts are used.

re:
Perhaps you have a better idea for returning the information to the Safety Director?
My suggestion stands : get rid of the useless HTML tags and background color.

Business mail should be business-like in appearance.

You *can* send HTML mail with a white background, using a single standard font like Arial,
bolding the headlines and/or paragraph headings, using a larger font size for headlines,
and keeping the use of color to a minimum...or even not using it at all.

Your Safety Director will appreciate that in your business report, I'm sure.

I formatted this response as HTML to show you what the ASP101
sample looks like when formatted with business mail in mind:

-------------

Sample Message
This message was sent from a sample at ASP101.

It is used to show people how to send HTML formatted email from an ASP.NET page.
If you did not request this email yourself, your address was entered by one of our visitors.

We do not store these e-mail addresses

--------

Notice the difference...
Instead of the garish yellow background in the original sample, you have a clean, crisp, business
format.

Good luck and, if you run into more problems, post back.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"dancer" <da****@microsoft.comwrote in message news:uV*************@TK2MSFTNGP02.phx.gbl...
Thank you, Juan. I will try again.
You said, "I, personally, hate email sent to me as it's too gaudy, but to
each his own."
I assume you mean you hate HTML email. The reason I want HTML email is so
that the Safety Director can see what the supervisor entered in the online
investigation report in the SAME FORMAT as the supervisor saw it.
Perhaps you have a better idea for returning the information to the Safety
Director?
I would love another option.

"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:uq**************@TK2MSFTNGP02.phx.gbl...
>re:
!A part of Juan's reply was Something else : you *must* put all the HTML
!content in ONE line.

I meant : "all the HTML content in ONE line".

The sample at ASP101 places all the HTML content in ONE line,
even though it composes that single line in several lines.

That's why you need to use VbCrLf and the underscore ( _ ):
to COMPOSE a single line over several lines of code.

Confusing ? You betcha.

Also, you're inverting the order of the VbCrLf and the underscore,
which is why the sample is blowing up on you.

i.e., you have :

objMM.Body = DateTime.Now + " HI " & _
"<html>" & vbCrLf & vbCrLf & _
"<head>" & vbCrLf & vbCrLf & _
"</head>"& vbCrLf & vbCrLf & _
"<body>" & vbCrLf & vbCrLf & _

etc....

When what you should have is :

objMM.Body = DateTime.Now + " HI " _
& "<html>" & vbCrLf & vbCrLf _
& "<head>" & vbCrLf & vbCrLf _
& "</head>"& vbCrLf & vbCrLf _
& "<body>" & vbCrLf & vbCrLf _
etc...

i.e., the underscore goes at the end of the line
you want to break, BEFORE the ampersand on the next line.
>Even more confusing is adding unneeded HTML tags to an HTML body
which doesn't need them, unless you need to have a background color.

May 10 '07 #23

P: n/a
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:OF**************@TK2MSFTNGP04.phx.gbl...
re:
!I just need it to look like a form, which is pretty much what the web
page will look like.
!Is there any other way to do that?

No, there isn't. Use the HTML if you need it, and apparently you do.
Just don't go ga-ga on it.

:-)
And don't complain, or even be surprised, if some of your recipients reject
your emails because they're not plain text...

Some people are like that... ;-)

--
http://www.markrae.net

May 10 '07 #24

P: n/a
re:
!And don't complain, or even be surprised, if some of your recipients reject
!your emails because they're not plain text...

Sure, but he only wants supervisors to send reports
as HTML email to one person : his boss, the Safety Director.

I'm sure he'll explain to his boss that the reports are HTML-formatted so they look prettier.
Bosses like that. All he needs to do now is make sure his boss can read HTML email.

:-)


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Mark Rae" <ma**@markNOSPAMrae.netwrote in message news:%2***************@TK2MSFTNGP03.phx.gbl...
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:OF**************@TK2MSFTNGP04.phx.gbl...
>re:
!I just need it to look like a form, which is pretty much what the web page will look like.
!Is there any other way to do that?

No, there isn't. Use the HTML if you need it, and apparently you do.
Just don't go ga-ga on it.

:-)

And don't complain, or even be surprised, if some of your recipients reject your emails because
they're not plain text...

Some people are like that... ;-)

--
http://www.markrae.net

May 11 '07 #25

P: n/a
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:u5**************@TK2MSFTNGP05.phx.gbl...
re:
!And don't complain, or even be surprised, if some of your recipients
reject
!your emails because they're not plain text...

Sure, but he only wants supervisors to send reports
as HTML email to one person : his boss, the Safety Director.
Oh right - sorry, I didn't pick up on that...
I'm sure he'll explain to his boss that the reports are HTML-formatted so
they look prettier.
Bosses like that. All he needs to do now is make sure his boss can read
HTML email.

:-)
He might be lucky...!

--
http://www.markrae.net

May 11 '07 #26

P: n/a
ALSO, I will need to send the information to a database that accumulates all
the data for a review of total accidents. Would it be better to just make a
pretty report from that database?
Of course, I know nothing of code to send to a database. That's probably 10
times harder than what I'm trying now. Is it?

I appreciate your help.

"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:OF**************@TK2MSFTNGP04.phx.gbl...
re:
!I just need it to look like a form, which is pretty much what the web
page will look like.
!Is there any other way to do that?

No, there isn't. Use the HTML if you need it, and apparently you do.
Just don't go ga-ga on it.

:-)

re:
!I notice the validation code seems to want only one name before the
!@server.com and I don't know how to change it. Could you help me with
that?

Sure. Just substitute this ValidationExpression for the one you have now:

ValidationExpression="^[\w-]+(\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$"

Copy and past the whole line, so there's no transcription mistakes.

That RegExp matches 99.99% of e-mail addresses.

The {2,7} at the end leaves space for top level domains
as short as .do but leaves room for longer ones like .info, .museum, etc.

It also matches :
fi****************@server.com
so*******@mail.server.com
ja*********@some.com ( Notice the underscore )
fo*@foo.ca
fo*@foo.server.ca
fo*@foo.co.uk
fo*@someserver.info
fo*****@someserver.museum
...and many other combinations.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"dancer" <da****@microsoft.comwrote in message
news:eF**************@TK2MSFTNGP05.phx.gbl...
Juan and Mark,

We are kindred spirits on the garish appearance. I hate even WEB SITES
that are not designed with restraint and taste. And if there is EVER
anything that moves or talks on a web site, I leave it immediately!

Obviously, I have not clearly stated my problem and my goal.
At the moment, supervisors are filling out a paper form by hand with a
pen. That is delivered by truck mail to the safety director. It is then
put in the employee's individual file. This will take the place of
that.

Forms, as you know, have boxes, lines, directions, check boxes, large
fonts, small fonts.
I do not need color. I just need it to look like a form, which is pretty
much what the web page will look like.

Is there any other way to do that?

By the way, I have not seen the ASP101 in HTML, because the validation
section won't accept my e-mail. My e-mail is in the format of
firstname.lastname.@server.com. I notice the validation code seems to
want only one name before the @server.com and I don't know how to change
it. Could you help me with that?

Thank you
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:OU**************@TK2MSFTNGP05.phx.gbl...
re:
I assume you mean you hate HTML email.

Yes, I meant that, although I don't hate it for the HTML itself.
I hate it when background colors, garish font colors and many fonts are
used.

re:
Perhaps you have a better idea for returning the information to the
Safety Director?

My suggestion stands : get rid of the useless HTML tags and background
color.

Business mail should be business-like in appearance.

You *can* send HTML mail with a white background, using a single standard
font like Arial,
bolding the headlines and/or paragraph headings, using a larger font size
for headlines,
and keeping the use of color to a minimum...or even not using it at all.

Your Safety Director will appreciate that in your business report, I'm
sure.

I formatted this response as HTML to show you what the ASP101
sample looks like when formatted with business mail in mind:

-------------

Sample Message
This message was sent from a sample at ASP101.

It is used to show people how to send HTML formatted email from an
ASP.NET page.
If you did not request this email yourself, your address was entered by
one of our visitors.

We do not store these e-mail addresses

--------

Notice the difference...
Instead of the garish yellow background in the original sample, you have
a clean, crisp, business format.

Good luck and, if you run into more problems, post back.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"dancer" <da****@microsoft.comwrote in message
news:uV*************@TK2MSFTNGP02.phx.gbl...
Thank you, Juan. I will try again.
You said, "I, personally, hate email sent to me as it's too gaudy, but
to
each his own."
I assume you mean you hate HTML email. The reason I want HTML email is
so
that the Safety Director can see what the supervisor entered in the
online
investigation report in the SAME FORMAT as the supervisor saw it.
Perhaps you have a better idea for returning the information to the
Safety
Director?
I would love another option.
>
>
>
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:uq**************@TK2MSFTNGP02.phx.gbl...
>re:
>!A part of Juan's reply was Something else : you *must* put all the
HTML
>!content in ONE line.
>>
>I meant : "all the HTML content in ONE line".
>>
>The sample at ASP101 places all the HTML content in ONE line,
>even though it composes that single line in several lines.
>>
>That's why you need to use VbCrLf and the underscore ( _ ):
>to COMPOSE a single line over several lines of code.
>>
>Confusing ? You betcha.
>>
>Also, you're inverting the order of the VbCrLf and the underscore,
>which is why the sample is blowing up on you.
>>
>i.e., you have :
>>
>objMM.Body = DateTime.Now + " HI " & _
>"<html>" & vbCrLf & vbCrLf & _
>"<head>" & vbCrLf & vbCrLf & _
>"</head>"& vbCrLf & vbCrLf & _
>"<body>" & vbCrLf & vbCrLf & _
>>
>etc....
>>
>When what you should have is :
>>
>objMM.Body = DateTime.Now + " HI " _
>& "<html>" & vbCrLf & vbCrLf _
>& "<head>" & vbCrLf & vbCrLf _
>& "</head>"& vbCrLf & vbCrLf _
>& "<body>" & vbCrLf & vbCrLf _
>etc...
>>
>i.e., the underscore goes at the end of the line
>you want to break, BEFORE the ampersand on the next line.
>Even more confusing is adding unneeded HTML tags to an HTML body
>which doesn't need them, unless you need to have a background color.


May 11 '07 #27

P: n/a
"dancer" <da****@microsoft.comwrote in message
news:eU****************@TK2MSFTNGP06.phx.gbl...
ALSO, I will need to send the information to a database that accumulates
all the data for a review of total accidents. Would it be better to just
make a pretty report from that database?
Of course, I know nothing of code to send to a database. That's probably
10 times harder than what I'm trying now. Is it?
Hmm - I appreciate that you're a "newbie", but maybe you should take a step
back here and actually evaluate your requirements properly, and then come up
with a design which meets them all...

Is this principally a system for data gathering?

If so, then you will almost certainly want to use that as your starting
point...

Does the intended recipient of this report (which is causing you so much
trouble) have access to your network? If so, then there's absolutely no need
to email anything anywhere, as there are plenty of reporting solutions for
ASP.NET...

--
http://www.markrae.net

May 11 '07 #28

P: n/a
No, data gathering is a second goal.
The first goal is having a report in hand that looks like the form that they
are now filling out on paper.

Re: "....as there are plenty of reporting solutions for
ASP.NET.."
What kind of reporting solutions?

"Mark Rae" <ma**@markNOSPAMrae.netwrote in message
news:eW**************@TK2MSFTNGP06.phx.gbl...
"dancer" <da****@microsoft.comwrote in message
news:eU****************@TK2MSFTNGP06.phx.gbl...
>ALSO, I will need to send the information to a database that accumulates
all the data for a review of total accidents. Would it be better to just
make a pretty report from that database?
Of course, I know nothing of code to send to a database. That's probably
10 times harder than what I'm trying now. Is it?

Hmm - I appreciate that you're a "newbie", but maybe you should take a
step back here and actually evaluate your requirements properly, and then
come up with a design which meets them all...

Is this principally a system for data gathering?

If so, then you will almost certainly want to use that as your starting
point...

Does the intended recipient of this report (which is causing you so much
trouble) have access to your network? If so, then there's absolutely no
need to email anything anywhere, as there are plenty of reporting
solutions for ASP.NET...

--
http://www.markrae.net

May 11 '07 #29

P: n/a
What Mark is probably suggesting is that you create your application to
store the information in the database. There is no need for an email, as
your boss is likely to have access to your webserver.

If your boss can see the webserver, he can search through the accident
reports and display them on his screen just however you want him to see
them. Makes it MUCH more versatile.

If I was you, I would offer that as a solution, with the benefit of
searchable and much easier to gain statistics from as well, which makes it
also much easier to discover patterns in accidents. You can still send him
an email with a simple line to say a new report has been submitted and give
him a link to open it directly.

Go through the quickstart guide on www.asp.net and also try some of the
tutorials on the microsoft site for visual web developer 2005. It really
sounds like at the moment, you are out of your depth. As Mark says, you do
really need to step back, look at the bigger picture and offer various
solutions. You need to learn how to develop the solution. We are happy to
help or point you in the right direction, but I can't help thinking you have
quite a steep learning curve.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"dancer" <da****@microsoft.comwrote in message
news:uO*************@TK2MSFTNGP05.phx.gbl...
No, data gathering is a second goal.
The first goal is having a report in hand that looks like the form that
they are now filling out on paper.

Re: "....as there are plenty of reporting solutions for
>ASP.NET.."
What kind of reporting solutions?

"Mark Rae" <ma**@markNOSPAMrae.netwrote in message
news:eW**************@TK2MSFTNGP06.phx.gbl...
>"dancer" <da****@microsoft.comwrote in message
news:eU****************@TK2MSFTNGP06.phx.gbl...
>>ALSO, I will need to send the information to a database that accumulates
all the data for a review of total accidents. Would it be better to
just make a pretty report from that database?
Of course, I know nothing of code to send to a database. That's
probably 10 times harder than what I'm trying now. Is it?

Hmm - I appreciate that you're a "newbie", but maybe you should take a
step back here and actually evaluate your requirements properly, and then
come up with a design which meets them all...

Is this principally a system for data gathering?

If so, then you will almost certainly want to use that as your starting
point...

Does the intended recipient of this report (which is causing you so much
trouble) have access to your network? If so, then there's absolutely no
need to email anything anywhere, as there are plenty of reporting
solutions for ASP.NET...

--
http://www.markrae.net


May 11 '07 #30

P: n/a
"dancer" <da****@microsoft.comwrote in message
news:uO*************@TK2MSFTNGP05.phx.gbl...
>Re: "....as there are plenty of reporting solutions for
ASP.NET.."
What kind of reporting solutions?
http://www.gotreportviewer.com/
http://www.microsoft.com/sql/technol...g/default.mspx
http://support.businessobjects.com/d...r_net/vs_2005/
http://www.componentsource.com/produ...index-gbp.html
http://www.siberix.com

And many, many others - Google is your friend...

--
http://www.markrae.net

May 11 '07 #31

P: n/a
"David" <da*****************@revilloc.REMOVETHIS.comwrot e in message
news:uK**************@TK2MSFTNGP04.phx.gbl...
What Mark is probably suggesting is that you create your application to
store the information in the database. There is no need for an email, as
your boss is likely to have access to your webserver.

If your boss can see the webserver, he can search through the accident
reports and display them on his screen just however you want him to see
them. Makes it MUCH more versatile.
Correct.
--
http://www.markrae.net

May 11 '07 #32

P: n/a
Yes, I realize I have a steep learning curve.
Right now, I need something "quick and dirty" while I study, now that you've
pointed me in the right direction.
So I'm thinking the e-mail will solve it until I can create a more elegant
solution. Do you agree?
So you may be seeing more from me on this.

Thank you.
"David" <da*****************@revilloc.REMOVETHIS.comwrot e in message
news:uK**************@TK2MSFTNGP04.phx.gbl...
What Mark is probably suggesting is that you create your application to
store the information in the database. There is no need for an email, as
your boss is likely to have access to your webserver.

If your boss can see the webserver, he can search through the accident
reports and display them on his screen just however you want him to see
them. Makes it MUCH more versatile.

If I was you, I would offer that as a solution, with the benefit of
searchable and much easier to gain statistics from as well, which makes it
also much easier to discover patterns in accidents. You can still send him
an email with a simple line to say a new report has been submitted and
give him a link to open it directly.

Go through the quickstart guide on www.asp.net and also try some of the
tutorials on the microsoft site for visual web developer 2005. It really
sounds like at the moment, you are out of your depth. As Mark says, you do
really need to step back, look at the bigger picture and offer various
solutions. You need to learn how to develop the solution. We are happy to
help or point you in the right direction, but I can't help thinking you
have quite a steep learning curve.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"dancer" <da****@microsoft.comwrote in message
news:uO*************@TK2MSFTNGP05.phx.gbl...
>No, data gathering is a second goal.
The first goal is having a report in hand that looks like the form that
they are now filling out on paper.

Re: "....as there are plenty of reporting solutions for
>>ASP.NET.."
What kind of reporting solutions?

"Mark Rae" <ma**@markNOSPAMrae.netwrote in message
news:eW**************@TK2MSFTNGP06.phx.gbl...
>>"dancer" <da****@microsoft.comwrote in message
news:eU****************@TK2MSFTNGP06.phx.gbl.. .

ALSO, I will need to send the information to a database that
accumulates all the data for a review of total accidents. Would it be
better to just make a pretty report from that database?
Of course, I know nothing of code to send to a database. That's
probably 10 times harder than what I'm trying now. Is it?

Hmm - I appreciate that you're a "newbie", but maybe you should take a
step back here and actually evaluate your requirements properly, and
then come up with a design which meets them all...

Is this principally a system for data gathering?

If so, then you will almost certainly want to use that as your starting
point...

Does the intended recipient of this report (which is causing you so much
trouble) have access to your network? If so, then there's absolutely no
need to email anything anywhere, as there are plenty of reporting
solutions for ASP.NET...

--
http://www.markrae.net



May 11 '07 #33

P: n/a
These are all links to 3rd party solutions, which mean I have to learn
ASP.net, VB, AND the 3rd party software.
Is it not possible to do it just in the programming language??

"Mark Rae" <ma**@markNOSPAMrae.netwrote in message
news:OS****************@TK2MSFTNGP04.phx.gbl...
"dancer" <da****@microsoft.comwrote in message
news:uO*************@TK2MSFTNGP05.phx.gbl...
>>Re: "....as there are plenty of reporting solutions for
ASP.NET.."
What kind of reporting solutions?

http://www.gotreportviewer.com/
http://www.microsoft.com/sql/technol...g/default.mspx
http://support.businessobjects.com/d...r_net/vs_2005/
http://www.componentsource.com/produ...index-gbp.html
http://www.siberix.com

And many, many others - Google is your friend...

--
http://www.markrae.net

May 11 '07 #34

P: n/a
"dancer" <da****@microsoft.comwrote in message
news:ut***************@TK2MSFTNGP05.phx.gbl...
These are all links to 3rd party solutions, which mean I have to learn
ASP.net, VB, AND the 3rd party software.
The first three are all Microsoft solutions...
Is it not possible to do it just in the programming language??
Your learning curve is surely steep enough without trying to roll your own
reporting engine... :-)

--
http://www.markrae.net

May 11 '07 #35

P: n/a
Why not ask him what he would like?

Tell him he can have quick and dirty or he can have an all singing all
dancing system, but that the all singing all dancing will take you a little
longer. Personally, I would develop the code to put it into the database
(you must have much of that already done, just got to insert into the
database now) then give him database access and he can at least look at the
detail (albeit a bit rough) until you get a web page written.

Look at the examples on the net. Ask here (after looking at the examples).

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"dancer" <da****@microsoft.comwrote in message
news:eu****************@TK2MSFTNGP04.phx.gbl...
Yes, I realize I have a steep learning curve.
Right now, I need something "quick and dirty" while I study, now that
you've pointed me in the right direction.
So I'm thinking the e-mail will solve it until I can create a more elegant
solution. Do you agree?
So you may be seeing more from me on this.

Thank you.
"David" <da*****************@revilloc.REMOVETHIS.comwrot e in message
news:uK**************@TK2MSFTNGP04.phx.gbl...
>What Mark is probably suggesting is that you create your application to
store the information in the database. There is no need for an email, as
your boss is likely to have access to your webserver.

If your boss can see the webserver, he can search through the accident
reports and display them on his screen just however you want him to see
them. Makes it MUCH more versatile.

If I was you, I would offer that as a solution, with the benefit of
searchable and much easier to gain statistics from as well, which makes
it also much easier to discover patterns in accidents. You can still send
him an email with a simple line to say a new report has been submitted
and give him a link to open it directly.

Go through the quickstart guide on www.asp.net and also try some of the
tutorials on the microsoft site for visual web developer 2005. It really
sounds like at the moment, you are out of your depth. As Mark says, you
do really need to step back, look at the bigger picture and offer various
solutions. You need to learn how to develop the solution. We are happy to
help or point you in the right direction, but I can't help thinking you
have quite a steep learning curve.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"dancer" <da****@microsoft.comwrote in message
news:uO*************@TK2MSFTNGP05.phx.gbl...
>>No, data gathering is a second goal.
The first goal is having a report in hand that looks like the form that
they are now filling out on paper.

Re: "....as there are plenty of reporting solutions for
ASP.NET.."
What kind of reporting solutions?

"Mark Rae" <ma**@markNOSPAMrae.netwrote in message
news:eW**************@TK2MSFTNGP06.phx.gbl...
"dancer" <da****@microsoft.comwrote in message
news:eU****************@TK2MSFTNGP06.phx.gbl. ..

ALSO, I will need to send the information to a database that
accumulates all the data for a review of total accidents. Would it be
better to just make a pretty report from that database?
Of course, I know nothing of code to send to a database. That's
probably 10 times harder than what I'm trying now. Is it?

Hmm - I appreciate that you're a "newbie", but maybe you should take a
step back here and actually evaluate your requirements properly, and
then come up with a design which meets them all...

Is this principally a system for data gathering?

If so, then you will almost certainly want to use that as your starting
point...

Does the intended recipient of this report (which is causing you so
much trouble) have access to your network? If so, then there's
absolutely no need to email anything anywhere, as there are plenty of
reporting solutions for ASP.NET...

--
http://www.markrae.net




May 11 '07 #36

P: n/a
Juan,
Why do we need
<%@Page Language="VB" ClientTarget="downlevel"% ?

Thanks


"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:OF**************@TK2MSFTNGP04.phx.gbl...
re:
!I just need it to look like a form, which is pretty much what the web
page will look like.
!Is there any other way to do that?

No, there isn't. Use the HTML if you need it, and apparently you do.
Just don't go ga-ga on it.

:-)

re:
!I notice the validation code seems to want only one name before the
!@server.com and I don't know how to change it. Could you help me with
that?

Sure. Just substitute this ValidationExpression for the one you have now:

ValidationExpression="^[\w-]+(\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$"

Copy and past the whole line, so there's no transcription mistakes.

That RegExp matches 99.99% of e-mail addresses.

The {2,7} at the end leaves space for top level domains
as short as .do but leaves room for longer ones like .info, .museum, etc.

It also matches :
fi****************@server.com
so*******@mail.server.com
ja*********@some.com ( Notice the underscore )
fo*@foo.ca
fo*@foo.server.ca
fo*@foo.co.uk
fo*@someserver.info
fo*****@someserver.museum
...and many other combinations.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"dancer" <da****@microsoft.comwrote in message
news:eF**************@TK2MSFTNGP05.phx.gbl...
Juan and Mark,

We are kindred spirits on the garish appearance. I hate even WEB SITES
that are not designed with restraint and taste. And if there is EVER
anything that moves or talks on a web site, I leave it immediately!

Obviously, I have not clearly stated my problem and my goal.
At the moment, supervisors are filling out a paper form by hand with a
pen. That is delivered by truck mail to the safety director. It is then
put in the employee's individual file. This will take the place of
that.

Forms, as you know, have boxes, lines, directions, check boxes, large
fonts, small fonts.
I do not need color. I just need it to look like a form, which is pretty
much what the web page will look like.

Is there any other way to do that?

By the way, I have not seen the ASP101 in HTML, because the validation
section won't accept my e-mail. My e-mail is in the format of
firstname.lastname.@server.com. I notice the validation code seems to
want only one name before the @server.com and I don't know how to change
it. Could you help me with that?

Thank you
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:OU**************@TK2MSFTNGP05.phx.gbl...
re:
I assume you mean you hate HTML email.

Yes, I meant that, although I don't hate it for the HTML itself.
I hate it when background colors, garish font colors and many fonts are
used.

re:
Perhaps you have a better idea for returning the information to the
Safety Director?

My suggestion stands : get rid of the useless HTML tags and background
color.

Business mail should be business-like in appearance.

You *can* send HTML mail with a white background, using a single standard
font like Arial,
bolding the headlines and/or paragraph headings, using a larger font size
for headlines,
and keeping the use of color to a minimum...or even not using it at all.

Your Safety Director will appreciate that in your business report, I'm
sure.

I formatted this response as HTML to show you what the ASP101
sample looks like when formatted with business mail in mind:

-------------

Sample Message
This message was sent from a sample at ASP101.

It is used to show people how to send HTML formatted email from an
ASP.NET page.
If you did not request this email yourself, your address was entered by
one of our visitors.

We do not store these e-mail addresses

--------

Notice the difference...
Instead of the garish yellow background in the original sample, you have
a clean, crisp, business format.

Good luck and, if you run into more problems, post back.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"dancer" <da****@microsoft.comwrote in message
news:uV*************@TK2MSFTNGP02.phx.gbl...
Thank you, Juan. I will try again.
You said, "I, personally, hate email sent to me as it's too gaudy, but
to
each his own."
I assume you mean you hate HTML email. The reason I want HTML email is
so
that the Safety Director can see what the supervisor entered in the
online
investigation report in the SAME FORMAT as the supervisor saw it.
Perhaps you have a better idea for returning the information to the
Safety
Director?
I would love another option.
>
>
>
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:uq**************@TK2MSFTNGP02.phx.gbl...
>re:
>!A part of Juan's reply was Something else : you *must* put all the
HTML
>!content in ONE line.
>>
>I meant : "all the HTML content in ONE line".
>>
>The sample at ASP101 places all the HTML content in ONE line,
>even though it composes that single line in several lines.
>>
>That's why you need to use VbCrLf and the underscore ( _ ):
>to COMPOSE a single line over several lines of code.
>>
>Confusing ? You betcha.
>>
>Also, you're inverting the order of the VbCrLf and the underscore,
>which is why the sample is blowing up on you.
>>
>i.e., you have :
>>
>objMM.Body = DateTime.Now + " HI " & _
>"<html>" & vbCrLf & vbCrLf & _
>"<head>" & vbCrLf & vbCrLf & _
>"</head>"& vbCrLf & vbCrLf & _
>"<body>" & vbCrLf & vbCrLf & _
>>
>etc....
>>
>When what you should have is :
>>
>objMM.Body = DateTime.Now + " HI " _
>& "<html>" & vbCrLf & vbCrLf _
>& "<head>" & vbCrLf & vbCrLf _
>& "</head>"& vbCrLf & vbCrLf _
>& "<body>" & vbCrLf & vbCrLf _
>etc...
>>
>i.e., the underscore goes at the end of the line
>you want to break, BEFORE the ampersand on the next line.
>Even more confusing is adding unneeded HTML tags to an HTML body
>which doesn't need them, unless you need to have a background color.


May 11 '07 #37

P: n/a
re:
!Why do we need
!<%@Page Language="VB" ClientTarget="downlevel"% ?

You don't need it.

If you want to disable client-side form validation,
you can do so by adding the downlevel directive.

Doing so will ensure that only HTML 3.2 is sent to the browser.

If your people use IE 5+, IE 6 or IE 7, you can use :

<%@Page Language="VB"%>

You probably will want to disable ViewState and SessionState, too.
That will make the page "lighter".

<%@ Page Language="VB" EnableViewState= "false" EnableSessionState = "false" %>


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"dancer" <da****@microsoft.comwrote in message news:e0**************@TK2MSFTNGP06.phx.gbl...
Juan,
Why do we need
<%@Page Language="VB" ClientTarget="downlevel"% ?

Thanks


"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:OF**************@TK2MSFTNGP04.phx.gbl...
>re:
!I just need it to look like a form, which is pretty much what the web page will look like.
!Is there any other way to do that?

No, there isn't. Use the HTML if you need it, and apparently you do.
Just don't go ga-ga on it.

:-)

re:
!I notice the validation code seems to want only one name before the
!@server.com and I don't know how to change it. Could you help me with that?

Sure. Just substitute this ValidationExpression for the one you have now:

ValidationExpression="^[\w-]+(\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$"

Copy and past the whole line, so there's no transcription mistakes.

That RegExp matches 99.99% of e-mail addresses.

The {2,7} at the end leaves space for top level domains
as short as .do but leaves room for longer ones like .info, .museum, etc.

It also matches :
fi****************@server.com
so*******@mail.server.com
ja*********@some.com ( Notice the underscore )
fo*@foo.ca
fo*@foo.server.ca
fo*@foo.co.uk
fo*@someserver.info
fo*****@someserver.museum
...and many other combinations.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"dancer" <da****@microsoft.comwrote in message news:eF**************@TK2MSFTNGP05.phx.gbl...
Juan and Mark,

We are kindred spirits on the garish appearance. I hate even WEB SITES that are not designed
with restraint and taste. And if there is EVER anything that moves or talks on a web site, I
leave it immediately!

Obviously, I have not clearly stated my problem and my goal.
At the moment, supervisors are filling out a paper form by hand with a pen. That is delivered by
truck mail to the safety director. It is then put in the employee's individual file. This
will take the place of that.

Forms, as you know, have boxes, lines, directions, check boxes, large fonts, small fonts.
I do not need color. I just need it to look like a form, which is pretty much what the web page
will look like.

Is there any other way to do that?

By the way, I have not seen the ASP101 in HTML, because the validation section won't accept my
e-mail. My e-mail is in the format of firstname.lastname.@server.com. I notice the validation
code seems to want only one name before the @server.com and I don't know how to change it. Could
you help me with that?

Thank you
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:OU**************@TK2MSFTNGP05.phx.gbl...
re:
> I assume you mean you hate HTML email.

Yes, I meant that, although I don't hate it for the HTML itself.
I hate it when background colors, garish font colors and many fonts are used.

re:
> Perhaps you have a better idea for returning the information to the Safety Director?

My suggestion stands : get rid of the useless HTML tags and background color.

Business mail should be business-like in appearance.

You *can* send HTML mail with a white background, using a single standard font like Arial,
bolding the headlines and/or paragraph headings, using a larger font size for headlines,
and keeping the use of color to a minimum...or even not using it at all.

Your Safety Director will appreciate that in your business report, I'm sure.

I formatted this response as HTML to show you what the ASP101
sample looks like when formatted with business mail in mind:

-------------

Sample Message
This message was sent from a sample at ASP101.

It is used to show people how to send HTML formatted email from an ASP.NET page.
If you did not request this email yourself, your address was entered by one of our visitors.

We do not store these e-mail addresses

--------

Notice the difference...
Instead of the garish yellow background in the original sample, you have a clean, crisp,
business format.

Good luck and, if you run into more problems, post back.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"dancer" <da****@microsoft.comwrote in message news:uV*************@TK2MSFTNGP02.phx.gbl...
> Thank you, Juan. I will try again.
You said, "I, personally, hate email sent to me as it's too gaudy, but to
each his own."
I assume you mean you hate HTML email. The reason I want HTML email is so
that the Safety Director can see what the supervisor entered in the online
investigation report in the SAME FORMAT as the supervisor saw it.
Perhaps you have a better idea for returning the information to the Safety
Director?
I would love another option.

"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:uq**************@TK2MSFTNGP02.phx.gbl...
re:
!A part of Juan's reply was Something else : you *must* put all the HTML
!content in ONE line.

I meant : "all the HTML content in ONE line".

The sample at ASP101 places all the HTML content in ONE line,
even though it composes that single line in several lines.

That's why you need to use VbCrLf and the underscore ( _ ):
to COMPOSE a single line over several lines of code.

Confusing ? You betcha.

Also, you're inverting the order of the VbCrLf and the underscore,
which is why the sample is blowing up on you.

i.e., you have :

objMM.Body = DateTime.Now + " HI " & _
"<html>" & vbCrLf & vbCrLf & _
"<head>" & vbCrLf & vbCrLf & _
"</head>"& vbCrLf & vbCrLf & _
"<body>" & vbCrLf & vbCrLf & _

etc....

When what you should have is :

objMM.Body = DateTime.Now + " HI " _
& "<html>" & vbCrLf & vbCrLf _
& "<head>" & vbCrLf & vbCrLf _
& "</head>"& vbCrLf & vbCrLf _
& "<body>" & vbCrLf & vbCrLf _
etc...

i.e., the underscore goes at the end of the line
you want to break, BEFORE the ampersand on the next line.
> >Even more confusing is adding unneeded HTML tags to an HTML body
which doesn't need them, unless you need to have a background color.



May 11 '07 #38

P: n/a
Hi Juan,
I'm back!!!!!
I know I have a LONG way to go, but I know a LOT more now than a week ago
when I started. You have clarified many things in the last couple days.
Can you tell me why my variables don't work?
I tried Dim Location As String = Location.Text but got error messages.
With this I don't get error messages, but neither does it return the value
of the variable.

Thank you again.

<@ Page Language="VB" ClientTarget="downlevel" %>
<%@ Import Namespace="System.Web.Mail" %>
<script language="VB" runat="server">
Sub btnSendMail_OnClick(Source As Object, E As EventArgs)

Dim Location As String = Location
Dim Who As String = Who
Dim Check1 As String
Dim myMessage As New MailMessage
Dim myMail As SmtpMail
Dim strEmail As String
If Page.IsValid() Then
strEmail = txtEmail.Text
'Location = Location.Text

myMessage.From = "xx*******@xxxxxxxxxx.com"
myMessage.To = strEmail
myMessage.Subject = "E-mail Sample (HTML)"

' This is the magic line. Without this the message will just appear
' as plain HTML and won't be rendered by the recipient's email client.
' It'd be as if they did "View Source" on a web page.
MyMessage.BodyFormat = MailFormat.Html

' This is multi-lined simply for readability.
' Notice that it is a properly formatted HTML
' message and not just plain text like most email.
' A lot of people have asked how to use form data
' in the emails so I added an example of including
' the entered address in the body of the email.
myMessage.Body = "<h2>Wheeler's Accident Investigation Form</h2>" &
vbCrLf _
& " <p>" & vbCrLf _
& " Place where accident occurred: " & location & "<br>" & vbCrLf _
& " Who was injured:" & who & "<br>" & vbCrLf _
& " Employer's Premises?" & check1 & "<br>"

' Doesn't have to be local... just enter your
' SMTP server's name or ip address!
myMail.SmtpServer = ""
myMail.Send(myMessage)

frmEmail.Visible = False
lblUserMessage.Text = "An HTML-formatted email message has been sent to "
& strEmail & "."
lblUserMessage.Text = "Place of accident" & location
End If
End Sub
</script>

<html>
<head>
<title>ASP.NET Email (HTML Format) Sample</title>
</head>
<body>

<table width="750" bgcolor="#E9EDF4" table border="1" cellpadding="3">
<h3><center><font face="Verdana">Wheeler's Accident Investigation
Form</font></center></h3>
<asp:Label id="lblUserMessage" text="Enter your e-mail address:"
runat="server" />
<form method="post" id="frmEmail" runat="server">
<asp:TextBox id="txtEmail" size="30" runat="server" />

<asp:RegularExpressionValidator runat="server"
id="validEmailRegExp" ControlToValidate="txtEmail"
ValidationExpression="^[\w-]+(\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$"
errormessage="Please enter a valid email address."
Display="Dynamic" />

<asp:Button id="btnSendMail" text="Send Mail!"
OnClick="btnSendMail_OnClick" runat="server" />
<hr>
<%--__________________________________________________ __________________________--% <%--ROW 1--% <td width="250" valign="top" <font face="Verdana" Size="2" Location where accident occurred: <asp:textbox id="Location"runat=server Width="200"/ </td <td align="right" valign="top" width="225" <font face="Verdana" Size="2">Employer's Premises <asp:CheckBox id=Check1 Text="yes" runat="server" / <asp:CheckBox id=Check2 Text="no" runat="server" / <brJob site <asp:CheckBox id=Check3 Text="yes" runat="server" / <asp:CheckBox id=Check4 Text="no" runat="server" /</td><td<font face="Verdana" Size="2">Date of accident</font><br <asp:textbox id="Date" runat=server Width="100"/></td <%--__________________________________________________ __________________________--%><%--ROW 2--%><tr<td <font face="Verdana" Size="2">Who was injured?</font><br<asp:textbox id="Who" runat=server width="200"/ </td <td align= "left"<font face="Verdana" Size="2">Employee <asp:CheckBox id=Check5runat="server" / <brNon-employee <asp:CheckBox id=Check6 runat="server" / </td <td align="right"><font face="Verdana" Size="2" Time of accident a.m. <asp:textbox id="am" runat=server Width="90"/ p.m. <asp:textbox id="pm" runat=server Width="90"/ </TD<%--__________________________________________________ __________________________--%><%--ROW 3--% <tr <td<font face="Verdana" Size="2">Date of Hire <br<asp:textbox id="Hiredate"runat=server/ </td <td<font face="Verdana" Size="2">Job Title or Occupation <br><asp:textboxid="occupation" runat=server width="200"/ </td <td <font face="Verdana" Size="2">How long has employee workedat job where injury occurred?<br><asp:textbox id="lengthofjob"runat=server/</td><%--__________________________________________________ __________________________--%><%--Row 4--% &nbsp&nbsp <p <asp:Label id=Label1 font-name="arial" font-size="10pt"runat="server"/></form><hr /></body></html>"Juan T. Llibre" <no***********@nowhere.comwrote in messagenews:uq**************@TK2MSFTNGP02.phx.gbl. ..re:!A part of Juan's reply was Something else : you *must* put all the HTML!content in ONE line.>I meant : "all the HTML content in ONE line".>The sample at ASP101 places all the HTML content in ONE line,even though it composes that single line in several lines.>That's why you need to use VbCrLf and the underscore ( _ ):to COMPOSE a single line over several lines of code.>Confusing ? You betcha.>Also, you're inverting the order of the VbCrLf and the underscore,which is why the sample is blowing up on you.>i.e., you have :>objMM.Body = DateTime.Now + " HI " & _"<html>" & vbCrLf & vbCrLf & _"<head>" & vbCrLf & vbCrLf & _"</head>"& vbCrLf & vbCrLf & _"<body>" & vbCrLf & vbCrLf & _>etc....>When what you should have is :>objMM.Body = DateTime.Now + " HI " _& "<html>" & vbCrLf & vbCrLf _& "<head>" & vbCrLf & vbCrLf _& "</head>"& vbCrLf & vbCrLf _& "<body>" & vbCrLf & vbCrLf _etc...>i.e., the underscore goes at the end of the lineyou want to break, BEFORE the ampersand on the next line.>Even more confusing is adding unneeded HTML tags to an HTML bodywhich doesn't need them, unless you need to have a background color.>Here's a version of the ASP101 sample without theunneeded HTML tags and *with* HTML format :><%@ Page Language="VB" ClientTarget="downlevel" %><%@ Import Namespace="System.Web.Mail" %><script language="VB" runat="server">Sub btnSendMail_OnClick(Source As Object, E As EventArgs) Dim myMessage As New MailMessage Dim myMail As SmtpMail Dim strEmail As String> If Page.IsValid() Then strEmail = txtEmail.Text> myMessage.From = "admin@" & Request.ServerVariables("SERVER_NAME") myMessage.To = strEmail myMessage.Subject = "E-mail Sample (HTML)"> ' This is the magic line. Without this the message will just appear ' as plain HTML and won't be rendered by the recipient's email client. ' It'd be as if they did "View Source" on a web page. MyMessage.BodyFormat = MailFormat.Html> ' This is multi-lined simply for readability. ' Notice that it is a properly formatted HTML ' message and not just plain text like most email. ' A lot of people have asked how to use form data ' in the emails so I added an example of including ' the entered address in the body of the email. myMessage.Body = "<h2>Sample Message</h2>" & vbCrLf _ & " <p>" & vbCrLf _ & " This message was sent from a sample at" & vbCrLf _ & " <a href=""http://yourserver.com"">Your Server 101</a>." & vbCrLf _ & " It is used to show people how to send HTML" & vbCrLf _ & " formatted email from an ASP.NET page." & vbCrLf _ & " If you did not request this email yourself," & vbCrLf _ & " your address was entered by one of our" & vbCrLf _ & " visitors." & vbCrLf _ & " <strong>" & vbCrLf _ & " We do not store these e-mail addresses." & vbCrLf _ & " </strong>" & vbCrLf _ & " </p>" & vbCrLf _ & " <p><font size=""-1"">Please address all concerns to*****@yourserver.com.</font></p>" & vbCrLf _ & " <p><font size=""-1"">This message was sent to: " & strEmail &"</font></p>"> ' Doesn't have to be local... just enter your ' SMTP server's name or ip address! myMail.SmtpServer = "YourSMTPServer" myMail.Send(myMessage)> frmEmail.Visible = False lblUserMessage.Text = "An HTML-formatted email message has been sent to" & strEmail & "." End IfEnd Sub</script>><html><head><title>ASP.NET Email (HTML Format) Sample</title></head><body>><asp:Label id="lblUserMessage" text="Enter your e-mail address:"runat="server" /><form method="post" id="frmEmail" runat="server"><asp:TextBox id="txtEmail" size="30" runat="server" /><asp:RequiredFieldValidator runat="server" id="validEmailRequired" ControlToValidate="txtEmail" errormessage="Please enter an email address." display="Dynamic" /><asp:RegularExpressionValidator runat="server" id="validEmailRegExp" ControlToValidate="txtEmail" ValidationExpression="^[\w-]+@[\w-]+\.(com|net|org|edu|mil)$" errormessage="Please enter a valid email address." Display="Dynamic" />><asp:Button id="btnSendMail" text="Send Mail!"OnClick="btnSendMail_OnClick" runat="server" /></form>><hr />></body></html>>------------------>You'll see that it compiles just fine and sends perfectly formatted HTMLwithout the need for those extra HTML tags ( <html>, <head>, <body><meta...>.>Of course, if you want the yellow background, or any other color,or a background image, include the HTML tags.>I, personally, hate email sent to me as it's too gaudy, but to each hisown.>Make sure you substitute your SMTP server's name before running the page:>myMail.SmtpServer = "YourSMTPServer">>>>Juan T. Llibre, asp.net MVPasp.net faq : http://asp.net.do/faq/foros de asp.net, en español : http://asp.net.do/foros/==================================="dancer" <da****@microsoft.comwrote in messagenews:u9**************@TK2MSFTNGP05.phx.gbl. ..>Also, David,>I had asked why do I get this error message:>Compiler Error Message: BC30452: Operator '&' is not defined for typesString' and 'System.Web.UI.WebControls.TextBox'.>>>A part of Juan's reply was Something else : you *must* put all the HTMLcontent in ONE line.>>>Do you have any thoughts on that error message?>>>>>"David" <da*****************@revilloc.REMOVETHIS.comwrot e in messagenews:ux**************@TK2MSFTNGP03.phx.gbl. ..>>Ah,>>>>>Sorry, I have my newsreader on to ignore read messages.>>>>>The P tags break the lines in the rendered page. BR tags also breaklines (work as a hard wrap).>>>>>vbCrLf is a Visual Basic Carriage Return Line Feed. All this does isallow the source html wrap onto a new line, so that your line is not toolong.>>>>>If you want to use the same thing in C#, then it is something like...>>>>>email.Body = "This is my email body\nNow I am on a new line\nNote thebackslash and n to create a new line\n. I can't remember though, you mightneed \r\n to create a new line";>>>>>backslash n.>>>>>Is that what you looking for? This however doesn't affect your renderedoutput. use \n where there is vbcrlf, however, vbcrlf is a defined constant,and \n has to be in quotes.>>>>>What you could do though is...>>>>>string vbCrLf = "\n";>>>>>-->>Best regards,>>Dave Colliver.>>http://www.AshfieldFOCUS.com>>~~>>http://www.FOCUSPortals.com - Local franchises available>>"dancer" <da****@microsoft.comwrote in messagenews:u3**************@TK2MSFTNGP04.phx.gbl. ..>>>David,>>>>>>>Not exactly does this answer my question. Could you please check outJuan's answer to my first post on this subject and help me understand, sinceI was copying my code from this code.>>>>>>>Thank you.>>>>>>>>>>>"David" <da*****************@revilloc.REMOVETHIS.comwrot e in messagenews:%2****************@TK2MSFTNGP02.phx.gb l...>>>>The vbCrLf are purely to ensure that the line is not too long whengenerated. There is a problem with over long lines that when they doeventually wrap, it can disrupt your formatted email.>>>>>>>>>You will note that there are no br tags, but there are p tags <pand</p>. These are what cause <P>aragraph breaks. (Actually, they are for newparagraphs rather than breaking paragraphs).>>>>>>>>>Does this answer your question?>>>>>>>>>(Note, you probably can't press "Yes" below as you probably can't seeit. If you can, then you have better eyes than me, as I can't see it. :-)>>>>>>>>>-->>>>Best regards,>>>>Dave Colliver.>>>>http://www.AshfieldFOCUS.com>>>>~~>>>>http://www.FOCUSPortals.com - Local franchises available>>>>>>>>>"dancer" <da****@microsoft.comwrote in messagenews:uH**************@TK2MSFTNGP04.phx.gbl. ..>>>>>Hi Juan,>>>>>>>>>>>What is the difference in what I am trying to do and this? Why canTHEY break up the HTML content into different lines?>>>>>>>>>>>email_html.aspx>>>>>-------------------------------------------------------------------------------->>>>>>>>>>><%@ Page Language="VB" ClientTarget="downlevel" %>>>>>><%@ Import Namespace="System.Web.Mail" %>>>>>><script language="VB" runat="server">>>>>>Sub btnSendMail_OnClick(Source As Object, E As EventArgs)>>>>>Dim myMessage As New MailMessage>>>>>Dim myMail As SmtpMail>>>>>Dim strEmail As String>>>>>>>>>>>If Page.IsValid() Then>>>>>strEmail = txtEmail.Text>>>>>>>>>>>'myMessage.From = "webmaster@" &Request.ServerVariables("SERVER_NAME")>>>>>myMess age.From = "we*******@asp101.com">>>>>myMessage.To = strEmail>>>>>myMessage.Subject = "E-mail Sample (HTML) from ASP 101!">>>>>>>>>>>' This is the magic line. Without this the message will just appear>>>>>' as plain HTML and won't be rendered by the recipient's emailclient.>>>>>' It'd be as if they did "View Source" on a web page.>>>>>MyMessage.BodyFormat = MailFormat.Html>>>>>>>>>>>' This is multi-lined simply for readability.>>>>>' Notice that it is a properly formatted HTML>>>>>' message and not just plain text like most email.>>>>>' A lot of people have asked how to use form data>>>>>' in the emails so I added an example of including>>>>>' the entered address in the body of the email.>>>>>myMessage.Body = "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0Transitional//EN"">" & vbCrLf _>>>>>& "<html>" & vbCrLf _>>>>>& "<head>" & vbCrLf _>>>>>& " <title>Sample Message From ASP 101</title>" & vbCrLf _>>>>>& " <meta http-equiv=Content-Type content=""text/html;charset=iso-8859-1"">" & vbCrLf _>>>>>& "</head>" & vbCrLf _>>>>>& "<body bgcolor=""#FFFFCC"">" & vbCrLf _>>>>>& " <h2>Sample Message From ASP 101</h2>" & vbCrLf _>>>>>& " <p>" & vbCrLf _>>>>>& " This message was sent from a sample at" & vbCrLf _>>>>>& " <a href=""http://www.asp101.com"">ASP 101</a>." & vbCrLf _>>>>>& " It is used to show people how to send HTML" & vbCrLf _>>>>>& " formatted email from an ASP.NET page." & vbCrLf _>>>>>& " If you did not request this email yourself," & vbCrLf _>>>>>& " your address was entered by one of our" & vbCrLf _>>>>>& " visitors." & vbCrLf _>>>>>& " <strong>" & vbCrLf _>>>>>& " We do not store these e-mail addresses." & vbCrLf _>>>>>& " </strong>" & vbCrLf _>>>>>& " </p>" & vbCrLf _>>>>>& " <p><font size=""-1"">Please address all concerns towe*******@asp101.com.</font></p>" & vbCrLf _>>>>>& " <p><font size=""-1"">This message was sent to: " & strEmail &"</font></p>" & vbCrLf _>>>>>& "</body>" & vbCrLf _>>>>>& "</html>" & vbCrLf>>>>>>>>>>>' Doesn't have to be local... just enter your>>>>>' SMTP server's name or ip address!>>>>>myMail.SmtpServer = "localhost">>>>>myMail.Send(myMessage)>>>>>>>>>>>f rmEmail.Visible = False>>>>>lblUserMessage.Text = "An HTML-formatted email message has been sentto " & strEmail & ".">>>>>End If>>>>>End Sub>>>>></script>>>>>>>>>>>><html>>>>>><head>>>>>><title>ASP .NET Email (HTML Format) Sample</title>>>>>></head>>>>>><body>>>>>>>>>>>><asp:Label id="lblUserMessage" text="Enter your e-mail address:"runat="server" />>>>>><form method="post" id="frmEmail" runat="server">>>>>><asp:TextBox id="txtEmail" size="30" runat="server" />>>>>><asp:RequiredFieldValidator runat="server">>>>>id="validEmailRequired" ControlToValidate="txtEmail">>>>>errormessage="Ple ase enter an email address.">>>>>display="Dynamic" />>>>>><asp:RegularExpressionValidator runat="server">>>>>id="validEmailRegExp" ControlToValidate="txtEmail">>>>>ValidationExpress ion="^[\w-]+@[\w-]+\.(com|net|org|edu|mil)$">>>>>errormessage="Pleas e enter a valid email address.">>>>>Display="Dynamic" />>>>>>>>>>>><asp:Button id="btnSendMail" text="Send Mail!"OnClick="btnSendMail_OnClick" runat="server" />>>>>></form>>>>>>>>>>>><hr />>>>>>>>>>>><p>>>>>>Click <ahref="http://www.asp101.com/samples/email_html_aspx.asp">here</ato readabout and download the source code.>>>>></p>>>>>>>>>>>></body>>>>>></html>>>>>>>>>>>>>>>>>>-------------------------------------------------------------------------------->>>>>>>>>>>"Juan T. Llibre" <no***********@nowhere.comwrote in messagenews:%2****************@TK2MSFTNGP02.phx.gb l...>>>>>>You don't need to set the html/head/body tags within the HTML body>>>>>>...and, in the VbCrLf thread, we established that you can't useVbCrLf in HTML.>>>>>>>>>>>>>Something else : you *must* put all the HTML content in ONE line.>>>>>>You can't break the lines with code.>>>>>>>>>>>>>Get rid of all the "VbCrLf" and all the "&" and write all your HTMLin a single line,>>>>>>line-breaking the body's content with "<br />" or "<P... </P>" asneeded.>>>>>>>>>>>>>Also, you can't insert Textbox controls into your HTML.>>>>>>>>>>>>>So, Check1.Text is out, too.>>>>>>>>>>>>>If you want to reference their content, after a user fills them out,>>>>>>capture it to a variable and use that, before writing to the body.>>>>>>>>>>>>>insert :>>>>>>>>>>>>>Dim Check1 as String = Check1.Text>>>>>>Dim Check2 as String = Check2.Text>>>>>>Dim Location as String = Location.Text>>>>>>before "Dim objMM as New MailMessage()">>>>>>>>>>>>>and, when composing the body, use :>>>>>>>>>>>>>mail.Body="Hi, <p>The location where the accident occurred is :" &Location & "<br/>" & Check1 & ".">>>>>>' etc.>>>>>>>>>>>>>You *can* use the & to reference text variables.>>>>>>Notice the location of the quote marks.>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Jua n T. Llibre, asp.net MVP>>>>>>asp.net faq : http://asp.net.do/faq/>>>>>>foros de asp.net, en español : http://asp.net.do/foros/>>>>>>===================================>>>>>>"da ncer" <da****@microsoft.comwrote in messagenews:uU*************@TK2MSFTNGP05.phx.gbl.. .>>>>>>>Can somebody tell me why I get this message with the followingcode?>>>>>>>>>>>>>>>Compiler Error Message: BC30452: Operator '&' is not defined fortypes 'String' and>>>>>>>'System.Web.UI.WebControls.TextBox'.>>>> >>>>>>>>>>><html>>>>>>>>>>>>>>>><head>>>>>>>>>>>>> >>><% @Import Namespace="System.Web.Mail" %>>>>>>>>>>>>>>>><script language="VB" runat="server">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Sub btnSendFeedback_Click(sender as Object, e as EventArgs)>>>>>>>>>>>>>>>'Create an instance of the MailMessage class>>>>>>>>>>>>>>>Dim objMM as New MailMessage()>>>>>>>>>>>>>>>'Set the properties - send the email to the person who filled outthe>>>>>>>>>>>>>>>'feedback form.>>>>>>>>>>>>>>>objMM.To = "xx*****@xxxxxxx.com">>>>>>>>>>>>>>>>>>>>>>>objMM. From = "xx*****@xxxxxxx.com">>>>>>>>>>>>>>>'send in html format>>>>>>>>>>>>>>>objMM.BodyFormat = MailFormat.html>>>>>>>>>>>>>>>'Set the priority - options are High, Low, and Normal>>>>>>>>>>>>>>>objMM.Priority = MailPriority.Normal>>>>>>>>>>>>>>>'Set the subject>>>>>>>>>>>>>>>objMM.Subject = "Accident Investigation Form">>>>>>>>>>>>>>>>>>>>>>>'Set the body>>>>>>>>>>>>>>>objMM.Body = DateTime.Now + " HI " & _>>>>>>>>>>>>>>>"<html>" & vbCrLf & vbCrLf & _>>>>>>>>>>>>>>>"<head>" & vbCrLf & vbCrLf & _>>>>>>>>>>>>>>>"</head>"& vbCrLf & vbCrLf & _>>>>>>>>>>>>>>>"<body>" & vbCrLf & vbCrLf & _>>>>>>>>>>>>>>>Location where accident occurred:>>>>>>>>>>>>>>>Location.Text & _>>>>>>>>>>>>>>>"<br>"& _>>>>>>>>>>>>>>7Check1.Text & "." & vbCrLf & vbCrLf & _>>>>>>>>>>>>>>>vbCrLf &vbCrLf & _>>>>>>>>>>>>>>>Check2.Text & vbCrLf & _>>>>>>>>>>>>>>>"</td>" & vbCrLf & vbCrLf & _>>>>>>>>>>>>>>>"</body>" & vbCrLf & vbCrLf & _>>>>>>>>>>>>>>>"</html>">>>>>>>>>>>>>>>>>>>>>>>'Specify to use the default Smtp Server>>>>>>>>>>>>>>>SmtpMail.SmtpServer = "">>>>>>>>>>>>>>>'Now, to send the message, use the Send method of the SmtpMailclass>>>>>>>>>>>>>>>SmtpMail.Send(objMM)>> >>>>>>>>>>>>>panelSendEmail.Visible = false>>>>>>>>>>>>>>>panelMailSent.Visible = true>>>>>>>>>>>>>>>End Sub>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>></script>>>>>>>>>>>>>>>></head>>>>>>>>>>>>>>>>>>>>>>>><body>>>>>>>>>>>>>>>>< table width="750" bgcolor="#E9EDF4" table border="1"cellpadding="3">>>>>>>>>>>>>>>><h3><cent er><font face="Verdana">Wheeler's Accident InvestigationForm</font></h3>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><hr>>>>>>>>>>>>> >>>><%--__________________________________________________ __________________________--%>>>>>>>>>>>>>>>><%--ROW 1--%>>>>>>>>>>>>>>>>>>>>>>>><td width="250" valign="top">>>>>>>>>>>>>>>>>>>>>>>><form runat="server">>>>>>>>>>>>>>>><font face="Verdana" Size="2">>>>>>>>>>>>>>>>Location where accident occurred: <asp:textbox id="Location"runat=server Width="200"/>>>>>>>>>>>>>>>></td>>>>>>>>>>>>>>>><td align="right" valign="top" width="225">>>>>>>>>>>>>>>>>>>>>>>><font face="Verdana" Size="2">Employer's Premises>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><asp:CheckB ox id=Check1 Text="yes" runat="server" />>>>>>>>>>>>>>>><asp:CheckBox id=Check2 Text="no" runat="server" />>>>>>>>>>>>>>>><br>>>>>>>>>>>>>>>>>>>>>>>>Job site>>>>>>>>>>>>>>><asp:CheckBox id=Check3 Text="yes" runat="server" />>>>>>>>>>>>>>>><asp:CheckBox id=Check4 Text="no" runat="server" />>>>>>>>>>>>>>>>>>>>>>>></td>>>>>>>>>>>>>>>><td>>>>>>>>>>>>>>>><font face="Verdana" Size="2">Date of accident</font><br>>>>>>>>>>>>>>>><asp:textbox id="Date" runat=server Width="100"/>>>>>>>>>>>>>>>>>>>>>>>></td>>>>>>>>>>>>>>>>><%--__________________________________________________ __________________________--%>>>>>>>>>>>>>>>><%--ROW 2--%>>>>>>>>>>>>>>>>>>>>>>>><tr<td>>>>>>>>>>>>>>>><fo nt face="Verdana" Size="2">Who was injured?</font><br>>>>>>>>>>>>>>>><asp:textbox id="Who" runat=server width="200"/>>>>>>>>>>>>>>>></td>>>>>>>>>>>>>>>><td align= "left">>>>>>>>>>>>>>>><font face="Verdana" Size="2">Employee <asp:CheckBox id=Check5runat="server" />>>>>>>>>>>>>>>><br>>>>>>>>>>>>>>>>Non-employee <asp:CheckBox id=Check6 runat="server" />>>>>>>>>>>>>>>>>>>>>>>></td>>>>>>>>>>>>>>>><td align="right"><font face="Verdana" Size="2">>>>>>>>>>>>>>>>Time of accident a.m. <asp:textbox id="am" runat=serverWidth="90"/>>>>>>>>>>>>>>>>p.m. <asp:textbox id="pm" runat=server Width="90"/>>>>>>>>>>>>>>>></TD>>>>>>>>>>>>>>>>><%--__________________________________________________ __________________________--%>>>>>>>>>>>>>>>><%--ROW 3--%>>>>>>>>>>>>>>>><tr>>>>>>>>>>>>>>>><td>>>>>>>>>>> >>>>><font face="Verdana" Size="2">Date of Hire <br<asp:textboxid="Hiredate" runat=server/>>>>>>>>>>>>>>>></td>>>>>>>>>>>>>>>><td>>>>>>>>>>>>>>>><font face="Verdana" Size="2">Job Title or Occupation<br><asp:textbox id="occupation">>>>>>>runat=server width="200"/>>>>>>>>>>>>>>>></td>>>>>>>>>>>>>>>><td>>>>>>>>>>>>>>>><font face="Verdana" Size="2">How long has employee worked at jobwhere injury>>>>>>>occurred?<br><asp:textbox id="lengthofjob" runat=server/>>>>>>>>>>>>>>>></td>>>>>>>>>>>>>>>>><%--__________________________________________________ __________________________--%>>>>>>>>>>>>>>>><%--Row 4--%>>>>>>>>>>>>>>>>&nbsp&nbsp>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>><p>>>>>>>>>>>>>>>>>>>>>>>><asp:Label id=Label1 font-name="arial" font-size="10pt"runat="server"/>>>>>>>>>>>>>>>><!Copied from /smirnof>>>>>>>>>>>>>>>><asp:panel id="panelSendEmail" runat="server">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>><%--asp:textbox id= runat="server" /--%>>>>>>>>>>>>>>>><br>>>>>>>>>>>>>>>><b>Your Message:</b><br>>>>>>>>>>>>>>>><%--asp:textbox id="txtMessage" TextMode="MultiLine">>>>>>>>>>>>>>>Columns="40" Rows="10" runat="server" /--%>>>>>>>>>>>>>>>><p>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ><asp:button runat="server" id="btnSendFeedback" Text="Send>>>>>>>>>>>>>>>Feedback!">>>>>>>>>>>>>>> OnClick="btnSendFeedback_Click" />>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>></asp:panel>>>>>>>>>>>>>>>><asp:panel id="panelMailSent" runat="server" Visible="False">>>>>>>>>>>>>>>>An email has been sent to the email address you specified.>>>>>>>>>>>>>>>Thanks!>>>>>>>>>>>>>>></asp:panel>>>>>>>>>>>>>>>></form>>>>>>>>>>>>>>>></body>>>>>>>>>>>>>>>></html>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

May 11 '07 #39

P: n/a
If Location is a text box, then when you dim Location, you are effectively
trying to redefine Location. As you dim it as a string, the string does not
have a .Text value, so yes, it will fail.

Try...

Dim MyLocation As String = Location.Text

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"dancer" <da****@microsoft.comwrote in message
news:Oz**************@TK2MSFTNGP06.phx.gbl...
Hi Juan,
I'm back!!!!!
I know I have a LONG way to go, but I know a LOT more now than a week ago
when I started. You have clarified many things in the last couple days.
Can you tell me why my variables don't work?
I tried Dim Location As String = Location.Text but got error
messages.
With this I don't get error messages, but neither does it return the value
of the variable.

Thank you again.

<@ Page Language="VB" ClientTarget="downlevel" %>
<%@ Import Namespace="System.Web.Mail" %>
<script language="VB" runat="server">
Sub btnSendMail_OnClick(Source As Object, E As EventArgs)

Dim Location As String = Location
Dim Who As String = Who
Dim Check1 As String
Dim myMessage As New MailMessage
Dim myMail As SmtpMail
Dim strEmail As String
If Page.IsValid() Then
strEmail = txtEmail.Text
'Location = Location.Text

myMessage.From = "xx*******@xxxxxxxxxx.com"
myMessage.To = strEmail
myMessage.Subject = "E-mail Sample (HTML)"

' This is the magic line. Without this the message will just appear
' as plain HTML and won't be rendered by the recipient's email client.
' It'd be as if they did "View Source" on a web page.
MyMessage.BodyFormat = MailFormat.Html

' This is multi-lined simply for readability.
' Notice that it is a properly formatted HTML
' message and not just plain text like most email.
' A lot of people have asked how to use form data
' in the emails so I added an example of including
' the entered address in the body of the email.
myMessage.Body = "<h2>Wheeler's Accident Investigation Form</h2>" &
vbCrLf _
& " <p>" & vbCrLf _
& " Place where accident occurred: " & location & "<br>" & vbCrLf _
& " Who was injured:" & who & "<br>" & vbCrLf _
& " Employer's Premises?" & check1 & "<br>"

' Doesn't have to be local... just enter your
' SMTP server's name or ip address!
myMail.SmtpServer = ""
myMail.Send(myMessage)

frmEmail.Visible = False
lblUserMessage.Text = "An HTML-formatted email message has been sent to
" & strEmail & "."
lblUserMessage.Text = "Place of accident" & location
End If
End Sub
</script>

<html>
<head>
<title>ASP.NET Email (HTML Format) Sample</title>
</head>
<body>

<table width="750" bgcolor="#E9EDF4" table border="1" cellpadding="3">
<h3><center><font face="Verdana">Wheeler's Accident Investigation
Form</font></center></h3>
<asp:Label id="lblUserMessage" text="Enter your e-mail address:"
runat="server" />
<form method="post" id="frmEmail" runat="server">
<asp:TextBox id="txtEmail" size="30" runat="server" />

<asp:RegularExpressionValidator runat="server"
id="validEmailRegExp" ControlToValidate="txtEmail"
ValidationExpression="^[\w-]+(\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$"
errormessage="Please enter a valid email address."
Display="Dynamic" />

<asp:Button id="btnSendMail" text="Send Mail!"
OnClick="btnSendMail_OnClick" runat="server" />
<hr>
<%--__________________________________________________ __________________________--%>
<%--ROW 1--% <td width="250" valign="top" <font
face="Verdana" Size="2" Location where accident occurred:
<asp:textbox id="Location"runat=server Width="200"/ </td <td
align="right" valign="top" width="225" <font face="Verdana"
Size="2">Employer's Premises <asp:CheckBox id=Check1 Text="yes"
runat="server" / <asp:CheckBox id=Check2 Text="no" runat="server"
/ <brJob site <asp:CheckBox id=Check3 Text="yes" runat="server"
/ <asp:CheckBox id=Check4 Text="no" runat="server" /</td><td>
<font face="Verdana" Size="2">Date of accident</font><br <asp:textbox
id="Date" runat=server Width="100"/></td>
<%--__________________________________________________ __________________________--%><%--ROW
2--%><tr<td <font face="Verdana" Size="2">Who was injured?</font><br>
<asp:textbox id="Who" runat=server width="200"/ </td <td align=
"left"<font face="Verdana" Size="2">Employee <asp:CheckBox
id=Check5runat="server" / <brNon-employee <asp:CheckBox id=Check6
runat="server" / </td <td align="right"><font face="Verdana"
Size="2" Time of accident a.m. <asp:textbox id="am" runat=server
Width="90"/ p.m. <asp:textbox id="pm" runat=server Width="90"/ </TD>
<%--__________________________________________________ __________________________--%><%--ROW
3--% <tr <td<font face="Verdana" Size="2">Date of Hire <br>
<asp:textbox id="Hiredate"runat=server/ </td <td<font
face="Verdana" Size="2">Job Title or Occupation
<br><asp:textboxid="occupation" runat=server width="200"/ </td <td>
<font face="Verdana" Size="2">How long has employee workedat job where
injury occurred?<br><asp:textbox id="lengthofjob"runat=server/>
</td><%--__________________________________________________ __________________________--%><%--Row
4--% &nbsp&nbsp <p <asp:Label id=Label1 font-name="arial"
font-size="10pt"runat="server"/></form><hr /></body></html>"Juan T.
Llibre" <no***********@nowhere.comwrote in
messagenews:uq**************@TK2MSFTNGP02.phx.gbl. ..re:!A part of
Juan's reply was Something else : you *must* put all the HTML!content
in ONE line.>I meant : "all the HTML content in ONE line".>The sample
at ASP101 places all the HTML content in ONE line,even though it
composes that single line in several lines.>That's why you need to use
VbCrLf and the underscore ( _ ):to COMPOSE a single line over several
lines of code.>Confusing ? You betcha.>Also, you're inverting the
order of the VbCrLf and the underscore,which is why the sample is
blowing up on you.>i.e., you have :>objMM.Body = DateTime.Now + " HI "
& _"<html>" & vbCrLf & vbCrLf & _"<head>" & vbCrLf & vbCrLf & _>
"</head>"& vbCrLf & vbCrLf & _"<body>" & vbCrLf & vbCrLf & _>etc....>>
When what you should have is :>objMM.Body = DateTime.Now + " HI " _&
"<html>" & vbCrLf & vbCrLf _& "<head>" & vbCrLf & vbCrLf _&
"</head>"& vbCrLf & vbCrLf _& "<body>" & vbCrLf & vbCrLf _etc...>>
i.e., the underscore goes at the end of the lineyou want to break,
BEFORE the ampersand on the next line.>Even more confusing is adding
unneeded HTML tags to an HTML bodywhich doesn't need them, unless you
need to have a background color.>Here's a version of the ASP101 sample
without theunneeded HTML tags and *with* HTML format :><%@ Page
Language="VB" ClientTarget="downlevel" %><%@ Import
Namespace="System.Web.Mail" %><script language="VB" runat="server">Sub
btnSendMail_OnClick(Source As Object, E As EventArgs) Dim myMessage
As New MailMessage Dim myMail As SmtpMail Dim strEmail As
String> If Page.IsValid() Then strEmail = txtEmail.Text>>
myMessage.From = "admin@" & Request.ServerVariables("SERVER_NAME")>
myMessage.To = strEmail myMessage.Subject = "E-mail Sample
(HTML)"> ' This is the magic line. Without this the message will just
appear ' as plain HTML and won't be rendered by the recipient's email
client. ' It'd be as if they did "View Source" on a web page.>
MyMessage.BodyFormat = MailFormat.Html> ' This is multi-lined simply
for readability. ' Notice that it is a properly formatted HTML '
message and not just plain text like most email. ' A lot of people have
asked how to use form data ' in the emails so I added an example of
including ' the entered address in the body of the email.>
myMessage.Body = "<h2>Sample Message</h2>" & vbCrLf _ & " <p>" &
vbCrLf _ & " This message was sent from a sample at" & vbCrLf _ &
" <a href=""http://yourserver.com"">Your Server 101</a>." & vbCrLf _>
& " It is used to show people how to send HTML" & vbCrLf _ & "
formatted email from an ASP.NET page." & vbCrLf _ & " If you did not
request this email yourself," & vbCrLf _ & " your address was entered
by one of our" & vbCrLf _ & " visitors." & vbCrLf _ & "
<strong>" & vbCrLf _ & " We do not store these e-mail addresses." &
vbCrLf _ & " </strong>" & vbCrLf _ & " </p>" & vbCrLf _ & "
<p><font size=""-1"">Please address all concerns
to*****@yourserver.com.</font></p>" & vbCrLf _ & " <p><font
size=""-1"">This message was sent to: " & strEmail &"</font></p>"> '
Doesn't have to be local... just enter your ' SMTP server's name or ip
address! myMail.SmtpServer = "YourSMTPServer">
myMail.Send(myMessage)> frmEmail.Visible = False lblUserMessage.Text
= "An HTML-formatted email message has been sent to" & strEmail & ".">
End IfEnd Sub</script>><html><head><title>ASP.NET Email (HTML
Format) Sample</title></head><body>><asp:Label id="lblUserMessage"
text="Enter your e-mail address:"runat="server" /><form method="post"
id="frmEmail" runat="server"><asp:TextBox id="txtEmail" size="30"
runat="server" /><asp:RequiredFieldValidator runat="server">
id="validEmailRequired" ControlToValidate="txtEmail">
errormessage="Please enter an email address." display="Dynamic" />>
<asp:RegularExpressionValidator runat="server" id="validEmailRegExp"
ControlToValidate="txtEmail">
ValidationExpression="^[\w-]+@[\w-]+\.(com|net|org|edu|mil)$">
errormessage="Please enter a valid email address." Display="Dynamic"
/>><asp:Button id="btnSendMail" text="Send
Mail!"OnClick="btnSendMail_OnClick" runat="server" /></form>><hr />>>
</body></html>>------------------>You'll see that it compiles just
fine and sends perfectly formatted HTMLwithout the need for those extra
HTML tags ( <html>, <head>, <body><meta...>.>Of course, if you want the
yellow background, or any other color,or a background image, include the
HTML tags.>I, personally, hate email sent to me as it's too gaudy, but
to each hisown.>Make sure you substitute your SMTP server's name before
running the page:>myMail.SmtpServer = "YourSMTPServer">>>>Juan T.
Llibre, asp.net MVPasp.net faq : http://asp.net.do/faq/foros de
asp.net, en español : http://asp.net.do/foros/>
==================================="dancer" <da****@microsoft.comwrote
in messagenews:u9**************@TK2MSFTNGP05.phx.gbl. ..>Also, David,>I
had asked why do I get this error message:>Compiler Error Message:
BC30452: Operator '&' is not defined for typesString' and
'System.Web.UI.WebControls.TextBox'.>>>A part of Juan's reply was
Something else : you *must* put all the HTMLcontent in ONE line.>>>Do
you have any thoughts on that error message?>>>>>"David"
<da*****************@revilloc.REMOVETHIS.comwrot e in
messagenews:ux**************@TK2MSFTNGP03.phx.gbl. ..>>Ah,>>>>>Sorry, I
have my newsreader on to ignore read messages.>>>>>The P tags break the
lines in the rendered page. BR tags also breaklines (work as a hard
wrap).>>>>>vbCrLf is a Visual Basic Carriage Return Line Feed. All this
does isallow the source html wrap onto a new line, so that your line is
not toolong.>>>>>If you want to use the same thing in C#, then it is
something like...>>>>>email.Body = "This is my email body\nNow I am on a
new line\nNote thebackslash and n to create a new line\n. I can't remember
though, you mightneed \r\n to create a new line";>>>>>backslash n.>>>>>>
Is that what you looking for? This however doesn't affect your
renderedoutput. use \n where there is vbcrlf, however, vbcrlf is a defined
constant,and \n has to be in quotes.>>>>>What you could do though
is...>>>>>string vbCrLf = "\n";>>>>>-->>Best regards,>>Dave
Colliver.>>http://www.AshfieldFOCUS.com>>~~>>>
http://www.FOCUSPortals.com - Local franchises available>>"dancer"
<da****@microsoft.comwrote in
messagenews:u3**************@TK2MSFTNGP04.phx.gbl. ..>>>David,>>>>>>>>
Not exactly does this answer my question. Could you please check
outJuan's answer to my first post on this subject and help me understand,
sinceI was copying my code from this code.>>>>>>>Thank you.>>>>>>>>>>>>
"David" <da*****************@revilloc.REMOVETHIS.comwrot e in
messagenews:%2****************@TK2MSFTNGP02.phx.gb l...>>>>The vbCrLf are
purely to ensure that the line is not too long whengenerated. There is a
problem with over long lines that when they doeventually wrap, it can
disrupt your formatted email.>>>>>>>>>You will note that there are no br
tags, but there are p tags <pand</p>. These are what cause <P>aragraph
breaks. (Actually, they are for newparagraphs rather than breaking
paragraphs).>>>>>>>>>Does this answer your question?>>>>>>>>>(Note,
you probably can't press "Yes" below as you probably can't seeit. If you
can, then you have better eyes than me, as I can't see it.
:-)>>>>>>>>>-->>>>Best regards,>>>>Dave Colliver.>>>>>
http://www.AshfieldFOCUS.com>>>>~~>>>>http://www.FOCUSPortals.com -
Local franchises available>>>>>>>>>"dancer" <da****@microsoft.comwrote
in messagenews:uH**************@TK2MSFTNGP04.phx.gbl. ..>>>>>Hi
Juan,>>>>>>>>>>>What is the difference in what I am trying to do and
this? Why canTHEY break up the HTML content into different
lines?>>>>>>>>>>>>
email_html.aspx>>>>>-------------------------------------------------------------------------------->>>>>>>>>>>>
<%@ Page Language="VB" ClientTarget="downlevel" %>>>>>><%@ Import
Namespace="System.Web.Mail" %>>>>>><script language="VB"
runat="server">>>>>>Sub btnSendMail_OnClick(Source As Object, E As
EventArgs)>>>>>Dim myMessage As New MailMessage>>>>>Dim myMail
As SmtpMail>>>>>Dim strEmail As String>>>>>>>>>>>If Page.IsValid()
Then>>>>>strEmail = txtEmail.Text>>>>>>>>>>>'myMessage.From =
"webmaster@" &Request.ServerVariables("SERVER_NAME")>>>>>myMess age.From
= "we*******@asp101.com">>>>>myMessage.To = strEmail>>>>>>
myMessage.Subject = "E-mail Sample (HTML) from ASP 101!">>>>>>>>>>>'
This is the magic line. Without this the message will just appear>>>>>'
as plain HTML and won't be rendered by the recipient's emailclient.>>>>>>
' It'd be as if they did "View Source" on a web page.>>>>>>
MyMessage.BodyFormat = MailFormat.Html>>>>>>>>>>>' This is multi-lined
simply for readability.>>>>>' Notice that it is a properly formatted
HTML>>>>>' message and not just plain text like most email.>>>>>' A
lot of people have asked how to use form data>>>>>' in the emails so I
added an example of including>>>>>' the entered address in the body of
the email.>>>>>myMessage.Body = "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD
HTML 4.0Transitional//EN"">" & vbCrLf _>>>>>& "<html>" & vbCrLf _>>>>>>
& "<head>" & vbCrLf _>>>>>& " <title>Sample Message From ASP
101</title>" & vbCrLf _>>>>>& " <meta http-equiv=Content-Type
content=""text/html;charset=iso-8859-1"">" & vbCrLf _>>>>>& "</head>" &
vbCrLf _>>>>>& "<body bgcolor=""#FFFFCC"">" & vbCrLf _>>>>>& "
<h2>Sample Message From ASP 101</h2>" & vbCrLf _>>>>>& " <p>" & vbCrLf
_>>>>>& " This message was sent from a sample at" & vbCrLf _>>>>>& "
<a href=""http://www.asp101.com"">ASP 101</a>." & vbCrLf _>>>>>& " It
is used to show people how to send HTML" & vbCrLf _>>>>>& " formatted
email from an ASP.NET page." & vbCrLf _>>>>>& " If you did not request
this email yourself," & vbCrLf _>>>>>& " your address was entered by
one of our" & vbCrLf _>>>>>& " visitors." & vbCrLf _>>>>>& "
<strong>" & vbCrLf _>>>>>& " We do not store these e-mail addresses." &
vbCrLf _>>>>>& " </strong>" & vbCrLf _>>>>>& " </p>" & vbCrLf _>>>>>>
& " <p><font size=""-1"">Please address all concerns
towe*******@asp101.com.</font></p>" & vbCrLf _>>>>>& " <p><font
size=""-1"">This message was sent to: " & strEmail &"</font></p>" & vbCrLf
_>>>>>& "</body>" & vbCrLf _>>>>>& "</html>" & vbCrLf>>>>>>>>>>>'
Doesn't have to be local... just enter your>>>>>' SMTP server's name or
ip address!>>>>>myMail.SmtpServer = "localhost">>>>>>
myMail.Send(myMessage)>>>>>>>>>>>frmEmail.Visible = False>>>>>>
lblUserMessage.Text = "An HTML-formatted email message has been sentto " &
strEmail & ".">>>>>End If>>>>>End Sub>>>>></script>>>>>>>>>>>>>
<html>>>>>><head>>>>>><title>ASP.NET Email (HTML Format)
Sample</title>>>>>></head>>>>>><body>>>>>>>>>>>><asp:Label
id="lblUserMessage" text="Enter your e-mail address:"runat="server"
/>>>>>><form method="post" id="frmEmail" runat="server">>>>>>>
<asp:TextBox id="txtEmail" size="30" runat="server" />>>>>>>
<asp:RequiredFieldValidator runat="server">>>>>id="validEmailRequired"
ControlToValidate="txtEmail">>>>>errormessage="Ple ase enter an email
address.">>>>>display="Dynamic" />>>>>><asp:RegularExpressionValidator
runat="server">>>>>id="validEmailRegExp"
ControlToValidate="txtEmail">>>>>>
ValidationExpression="^[\w-]+@[\w-]+\.(com|net|org|edu|mil)$">>>>>>
errormessage="Please enter a valid email address.">>>>>Display="Dynamic"
/>>>>>>>>>>>><asp:Button id="btnSendMail" text="Send
Mail!"OnClick="btnSendMail_OnClick" runat="server" />>>>>>>
</form>>>>>>>>>>>><hr />>>>>>>>>>>><p>>>>>>Click
<ahref="http://www.asp101.com/samples/email_html_aspx.asp">here</ato
readabout and download the source code.>>>>></p>>>>>>>>>>>>>
</body>>>>>>>
</html>>>>>>>>>>>>>>>>>>-------------------------------------------------------------------------------->>>>>>>>>>>>
"Juan T. Llibre" <no***********@nowhere.comwrote in
messagenews:%2****************@TK2MSFTNGP02.phx.gb l...>>>>>>You don't
need to set the html/head/body tags within the HTML body>>>>>>...and, in
the VbCrLf thread, we established that you can't useVbCrLf in
HTML.>>>>>>>>>>>>>Something else : you *must* put all the HTML content
in ONE line.>>>>>>You can't break the lines with code.>>>>>>>>>>>>>Get
rid of all the "VbCrLf" and all the "&" and write all your HTMLin a single
line,>>>>>>line-breaking the body's content with "<br />" or "<P...
</P>" asneeded.>>>>>>>>>>>>>Also, you can't insert Textbox controls into
your HTML.>>>>>>>>>>>>>So, Check1.Text is out, too.>>>>>>>>>>>>>If you
want to reference their content, after a user fills them out,>>>>>>>
capture it to a variable and use that, before writing to the
body.>>>>>>>>>>>>>insert :>>>>>>>>>>>>>Dim Check1 as String =
Check1.Text>>>>>>Dim Check2 as String = Check2.Text>>>>>>Dim Location
as String = Location.Text>>>>>>before "Dim objMM as New
MailMessage()">>>>>>>>>>>>>and, when composing the body, use
:>>>>>>>>>>>>>mail.Body="Hi, <p>The location where the accident occurred
is :" &Location & "<br/>" & Check1 & ".">>>>>>' etc.>>>>>>>>>>>>>You
*can* use the & to reference text variables.>>>>>>Notice the location of
the quote marks.>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Jua n T. Llibre,
asp.net MVP>>>>>>asp.net faq : http://asp.net.do/faq/>>>>>>foros de
asp.net, en español : http://asp.net.do/foros/>>>>>>>
===================================>>>>>>"dancer" <da****@microsoft.com>
wrote in messagenews:uU*************@TK2MSFTNGP05.phx.gbl.. .>>>>>>>Can
somebody tell me why I get this message with the
followingcode?>>>>>>>>>>>>>>>Compiler Error Message: BC30452: Operator
'&' is not defined fortypes 'String' and>>>>>>>>
'System.Web.UI.WebControls.TextBox'.>>>>>>>>>>>>>> >>
<html>>>>>>>>>>>>>>>><head>>>>>>>>>>>>>>>><% @Import
Namespace="System.Web.Mail" %>>>>>>>>>>>>>>>><script language="VB"
runat="server">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Sub
btnSendFeedback_Click(sender as Object, e as EventArgs)>>>>>>>>>>>>>>>>
'Create an instance of the MailMessage class>>>>>>>>>>>>>>>Dim objMM as
New MailMessage()>>>>>>>>>>>>>>>'Set the properties - send the email to
the person who filled outthe>>>>>>>>>>>>>>>'feedback
form.>>>>>>>>>>>>>>>objMM.To =
"xx*****@xxxxxxx.com">>>>>>>>>>>>>>>>>>>>>>>objMM. From =
"xx*****@xxxxxxx.com">>>>>>>>>>>>>>>'send in html format>>>>>>>>>>>>>>>>
objMM.BodyFormat = MailFormat.html>>>>>>>>>>>>>>>'Set the priority -
options are High, Low, and Normal>>>>>>>>>>>>>>>objMM.Priority =
MailPriority.Normal>>>>>>>>>>>>>>>'Set the subject>>>>>>>>>>>>>>>>
objMM.Subject = "Accident Investigation Form">>>>>>>>>>>>>>>>>>>>>>>'Set
the body>>>>>>>>>>>>>>>objMM.Body = DateTime.Now + " HI " &
_>>>>>>>>>>>>>>>"<html>" & vbCrLf & vbCrLf & _>>>>>>>>>>>>>>>"<head>"
& vbCrLf & vbCrLf & _>>>>>>>>>>>>>>>"</head>"& vbCrLf & vbCrLf &
_>>>>>>>>>>>>>>>"<body>" & vbCrLf & vbCrLf & _>>>>>>>>>>>>>>>Location
where accident occurred:>>>>>>>>>>>>>>>Location.Text & _>>>>>>>>>>>>>>>>
"<br>"& _>>>>>>>>>>>>>>7Check1.Text & "." & vbCrLf & vbCrLf &
_>>>>>>>>>>>>>>>vbCrLf &vbCrLf & _>>>>>>>>>>>>>>>Check2.Text & vbCrLf
& _>>>>>>>>>>>>>>>"</td>" & vbCrLf & vbCrLf & _>>>>>>>>>>>>>>>>
"</body>" & vbCrLf & vbCrLf & _>>>>>>>>>>>>>>>>
"</html>">>>>>>>>>>>>>>>>>>>>>>>'Specify to use the default Smtp
Server>>>>>>>>>>>>>>>SmtpMail.SmtpServer = "">>>>>>>>>>>>>>>'Now, to
send the message, use the Send method of the SmtpMailclass>>>>>>>>>>>>>>>>
SmtpMail.Send(objMM)>>>>>>>>>>>>>>>panelSendEmail. Visible =
false>>>>>>>>>>>>>>>panelMailSent.Visible = true>>>>>>>>>>>>>>>End
Sub>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>></script>>>>>>>>>>>>>>>>>
</head>>>>>>>>>>>>>>>>>>>>>>>><body>>>>>>>>>>>>>>>>< table width="750"
bgcolor="#E9EDF4" table border="1"cellpadding="3">>>>>>>>>>>>>>>>>
<h3><center><font face="Verdana">Wheeler's Accident
InvestigationForm</font></h3>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<hr>>>>>>>>>>>>>>>>><%--__________________________________________________ __________________________--%>>>>>>>>>>>>>>>>>
<%--ROW 1--%>>>>>>>>>>>>>>>>>>>>>>>><td width="250"
valign="top">>>>>>>>>>>>>>>>>>>>>>>><form
runat="server">>>>>>>>>>>>>>>><font face="Verdana"
Size="2">>>>>>>>>>>>>>>>Location where accident occurred: <asp:textbox
id="Location"runat=server Width="200"/>>>>>>>>>>>>>>>>>
</td>>>>>>>>>>>>>>>><td align="right" valign="top"
width="225">>>>>>>>>>>>>>>>>>>>>>>><font face="Verdana"
Size="2">Employer's Premises>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><asp:CheckB ox
id=Check1 Text="yes" runat="server" />>>>>>>>>>>>>>>><asp:CheckBox
id=Check2 Text="no" runat="server" />>>>>>>>>>>>>>>>>
<br>>>>>>>>>>>>>>>>>>>>>>>>Job site>>>>>>>>>>>>>>><asp:CheckBox
id=Check3 Text="yes" runat="server" />>>>>>>>>>>>>>>><asp:CheckBox
id=Check4 Text="no" runat="server" />>>>>>>>>>>>>>>>>>>>>>>>>
</td>>>>>>>>>>>>>>>><td>>>>>>>>>>>>>>>><font face="Verdana"
Size="2">Date of accident</font><br>>>>>>>>>>>>>>>><asp:textbox
id="Date" runat=server Width="100"/>>>>>>>>>>>>>>>>>>>>>>>>>
</td>>>>>>>>>>>>>>>>><%--__________________________________________________ __________________________--%>>>>>>>>>>>>>>>>>
<%--ROW 2--%>>>>>>>>>>>>>>>>>>>>>>>><tr<td>>>>>>>>>>>>>>>><fo nt
face="Verdana" Size="2">Who was injured?</font><br>>>>>>>>>>>>>>>>>
<asp:textbox id="Who" runat=server width="200"/>>>>>>>>>>>>>>>>>
</td>>>>>>>>>>>>>>>><td align= "left">>>>>>>>>>>>>>>><font
face="Verdana" Size="2">Employee <asp:CheckBox id=Check5runat="server"
/>>>>>>>>>>>>>>>><br>>>>>>>>>>>>>>>>Non-employee <asp:CheckBox
id=Check6 runat="server" />>>>>>>>>>>>>>>>>>>>>>>></td>>>>>>>>>>>>>>>>>
<td align="right"><font face="Verdana" Size="2">>>>>>>>>>>>>>>>Time of
accident a.m. <asp:textbox id="am"
runat=serverWidth="90"/>>>>>>>>>>>>>>>>p.m. <asp:textbox id="pm"
runat=server Width="90"/>>>>>>>>>>>>>>>>>
</TD>>>>>>>>>>>>>>>>><%--__________________________________________________ __________________________--%>>>>>>>>>>>>>>>>>
<%--ROW 3--%>>>>>>>>>>>>>>>><tr>>>>>>>>>>>>>>>><td>>>>>>>>>>> >>>>>>
<font face="Verdana" Size="2">Date of Hire <br<asp:textboxid="Hiredate"
runat=server/>>>>>>>>>>>>>>>></td>>>>>>>>>>>>>>>><td>>>>>>>>>>>>>>>>>
<font face="Verdana" Size="2">Job Title or Occupation<br><asp:textbox
id="occupation">>>>>>>runat=server width="200"/>>>>>>>>>>>>>>>>>
</td>>>>>>>>>>>>>>>><td>>>>>>>>>>>>>>>><font face="Verdana"
Size="2">How long has employee worked at jobwhere injury>>>>>>>>
occurred?<br><asp:textbox id="lengthofjob" runat=server/>>>>>>>>>>>>>>>>>
</td>>>>>>>>>>>>>>>>><%--__________________________________________________ __________________________--%>>>>>>>>>>>>>>>>>
<%--Row 4--%>>>>>>>>>>>>>>>>&nbsp&nbsp>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>
<p>>>>>>>>>>>>>>>>>>>>>>>><asp:Label id=Label1 font-name="arial"
font-size="10pt"runat="server"/>>>>>>>>>>>>>>>><!Copied from
/smirnof>>>>>>>>>>>>>>>><asp:panel id="panelSendEmail"
runat="server">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>
<%--asp:textbox id= runat="server" /--%>>>>>>>>>>>>>>>>>
<br>>>>>>>>>>>>>>>><b>Your Message:</b><br>>>>>>>>>>>>>>>>>
<%--asp:textbox id="txtMessage" TextMode="MultiLine">>>>>>>>>>>>>>>>
Columns="40" Rows="10" runat="server" /--%>>>>>>>>>>>>>>>>>
<p>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><asp:button runat="server"
id="btnSendFeedback" Text="Send>>>>>>>>>>>>>>>Feedback!">>>>>>>>>>>>>>> >
OnClick="btnSendFeedback_Click" />>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
</asp:panel>>>>>>>>>>>>>>>><asp:panel id="panelMailSent" runat="server"
Visible="False">>>>>>>>>>>>>>>>An email has been sent to the email
address you specified.>>>>>>>>>>>>>>>Thanks!>>>>>>>>>>>>>>>>
</asp:panel>>>>>>>>>>>>>>>></form>>>>>>>>>>>>>>>>>
</body>>>>>>>>>>>>>>>>>
</html>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

May 12 '07 #40

This discussion thread is closed

Replies have been disabled for this discussion.