Try ControlChars.vbCrLf instead of just vbCrLf.
You are using VB.NET. The Microsoft.VisualBasic namespace is likely
available (unless you changed the project default).
Patrice
--
"Joe" <> a écrit dans le message de
news:6E93BEC3-4AA1-4560-B200-...
> Hi,
>
> I have a simple form that does nothing but emails the whatever user
entered
> in the form fields. The form is working fine and email sent. The problem
I
> am having is in te string that forms the body of the email. I just want to
> insert line breaks using vbCrLf, but when I do that I get an error saying,
>
> Compiler Error Message: BC30451: Name 'vbCrLf' is not declared.
>
>
> The lins that gets highlighted is
>
> objMM.Body = "First Name: " & txtFirstName.Text & vbCrLf & vbCrLf & "Last
> Name: " & _
>
> To see what I am doing, I have pasted to the code from the code behind
file.
> As you can see I am using VB and C#. I would appreciate if you can give
me
> some idea as why vbCrLf is not working.
>
> Thanks in advance
>
> Joe
>
>
>
> Option Explicit On
> Option Strict On
>
> Imports System
> Imports System.IO
> Imports System.Web.UI.WebControls
> Imports System.Data
> Imports System.Data.OleDb
> Imports System.Web.Mail
>
>
> Public Class sendForm : Inherits System.Web.UI.Page
>
> Protected WithEvents txtFirstName As System.Web.UI.WebControls.TextBox
> Protected WithEvents txtLastName As System.Web.UI.WebControls.TextBox
> Protected WithEvents txtCompany As System.Web.UI.WebControls.TextBox
> Protected WithEvents txtTitle As System.Web.UI.WebControls.TextBox
> Protected WithEvents txtPhone As System.Web.UI.WebControls.TextBox
> Protected WithEvents txtEmail As System.Web.UI.WebControls.TextBox
> Protected WithEvents txtReferrer As System.Web.UI.WebControls.TextBox
> Protected WithEvents btnSubmit As System.Web.UI.WebControls.Button
>
> 'Public Const microsoft.visualbasic.Constants.vbCrLf as String =
> Microsoft.VisualBasic.ControlChars.vbCrLf
>
> Sub Submit(ByVal sender As System.Object, ByVal e As System.EventArgs)
>
> Dim objMM as New MailMessage()
> objMM.To = ""
> objMM.From = ""
> objMM.BodyFormat = MailFormat.Html
> objMM.Priority = MailPriority.Normal
> objMM.Subject = "Form details"
>
> 'Set the body
> objMM.Body = "First Name: " & txtFirstName.Text & vbCrLf & vbCrLf &
> "Last Name: " & _
> txtLastName.Text & vbCrLf & vbCrLf & "Company: " &
> txtCompany.Text & vbCrLf & vbCrLf & _
> "Title: " & txtTitle.Text & vbCrLf & vbCrLf & "Phone: " &
> txtPhone.Text & vbCrLf & vbCrLf & _
> "Email: " & txtEmail.Text & vbCrLf & vbCrLf & "Referrer: " &
> txtReferrer.Text & vbCrLf & vbCrLf & _
> "Timestamp: " & DateTime.Now() & vbCrLf & vbCrLf & "IP address: " &
> Request.UserHostAddress()
>
> SmtpMail.SmtpServer = ""
> SmtpMail.Send(objMM)
> End Sub
>
> End Class
>
|