Saturday, March 24, 2012

OPERATOR '&' IS NOT DEFINED

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>
<% @dotnet.itags.org.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 = "xxxxxxt@dotnet.itags.org.xxxxxxx.com"
objMM.From = "xxxxxxx@dotnet.itags.org.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 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><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--%>
  
<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>"dancer" <dancer@.microsoft.com> wrote in message
news:uUtpcLwkHHA.744@.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
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" <dancer@.microsoft.com> a crit dans le message de news:
uUtpcLwkHHA.744@.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 = "xxxxxxt@.xxxxxxx.com"
>
> objMM.From = "xxxxxxx@.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</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 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<br>
> <asp:textbox id="Date" runat=server Width="100"/>
>
> </td>
> <%-- ________________________________________
______________________________
______--%>
> <%--ROW 2--%>
>
> <tr> <td>
> <font face="Verdana" Size="2">Who was injured?<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><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--%>
>   
>
> <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>
>
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 H
TML.
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 sin
gle 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 espaol : http://asp.net.do/foros/
===================================
"dancer" <dancer@.microsoft.com> wrote in message news:uUtpcLwkHHA.744@.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 'St
ring' 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 = "xxxxxxt@.xxxxxxx.com"
>
> objMM.From = "xxxxxxx@.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>"& _
>
7> 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</fo
nt></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 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<br>
> <asp:textbox id="Date" runat=server Width="100"/>
>
> </td>
> <%-- ________________________________________
______________________________
______--%>
> <%--ROW 2--%>
>
> <tr> <td>
> <font face="Verdana" Size="2">Who was injured?<br>
> <asp:textbox id="Who" runat=server width="200"/>
> </td>
> <td align= "left">
> <font face="Verdana" Size="2">Employee <asp:CheckBox id=Check5 runat="serv
er" />
> <br>
> Non-employee <asp:CheckBox id=Check6 runat="server" />
>
> </td>
> <td><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 in
jury
> occurred?<br><asp:textbox id="lengthofjob" runat=server/>
> </td>
> <%-- ________________________________________
______________________________
______--%>
> <%--Row 4--%>
>   
>
> <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>
>
underprocessable
"dancer" <dancer@.microsoft.com> wrote in message
news:uHX9FPxkHHA.4152@.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...
What should I do? I copied code from ASP101 to ask a question about it.
"Mark Rae" <mark@.markNOSPAMrae.net> wrote in message
news:u8WlAZxkHHA.4628@.TK2MSFTNGP06.phx.gbl...
> "dancer" <dancer@.microsoft.com> wrote in message
> news:uHX9FPxkHHA.4152@.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...
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 = "webmaster@.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://links.10026.com/?link="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
webmaster@.asp101.com.</p>" & vbCrLf _
& " <p><font size=""-1"">This message was sent to: " & strEmail &
"</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://links.10026.com/?link=http://www.asp101.com/samples/email_html_aspx.asp">here</a>
to read about and download the source code.
</p>
</body>
</html>
"Mark Rae" <mark@.markNOSPAMrae.net> wrote in message
news:u8WlAZxkHHA.4628@.TK2MSFTNGP06.phx.gbl...
> "dancer" <dancer@.microsoft.com> wrote in message
> news:uHX9FPxkHHA.4152@.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...
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 <p> and </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" <dancer@.microsoft.com> wrote in message
news:uHX9FPxkHHA.4152@.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 = "webmaster@.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://links.10026.com/?link="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
> webmaster@.asp101.com.</p>" & vbCrLf _
> & " <p><font size=""-1"">This message was sent to: " & strEmail &
> "</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://links.10026.com/?link=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" <nomailreplies@.nowhere.com> wrote in message
> news:%231R59hwkHHA.1624@.TK2MSFTNGP02.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" <dancer@.microsoft.com> wrote in message
news:u3AxQ0xkHHA.1240@.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" <david.colliver.NEWS@.revilloc.REMOVETHIS.com> wrote in message
> news:%23FGYIpxkHHA.3484@.TK2MSFTNGP02.phx.gbl...
>

0 comments:

Post a Comment