[RESOLVED] How do I create a paragraph in an e-mail?
Hello everybody.
I have created a program that sends an e-mail but the body of my e-mail always creates one line of messages. For example, if I want to write Dear Tommy on the first paragraph and Dear Jhonny on the next. I can't seem to create paragraphs.
Re: How do I create a paragraph in an e-mail?
You can add a carriage return and a line feed inbetween your text.
VB Code:
MessageBox.Show("Dear Tommy" & ControlChars.CrLf & "Dear Jhonny")
Re: How do I create a paragraph in an e-mail?
:eek2: Runtime alert! ControlChars.CrLf? Environment.NewLine. :)
Re: How do I create a paragraph in an e-mail?
ControlChars is part of MS VB Namespace. You have said and provn that its the same thing but just not viewed as .NET code. :D
Anyways, lets not get into another looooog thread about MSVB Namespace. :D
Re: How do I create a paragraph in an e-mail?
Hmmm.... It didn't worked. There is defininitely something wrong with my code. Here have a look see.
VB Code:
'Week 2
Imports System.Web.Mail
Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Label1.Text = "Thomas"
Button1.Text = "Submit"
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim AutoEmail As New MailMessage
AutoEmail.To = Label2.Text
AutoEmail.Subject = "Test subject from VB.NET"
AutoEmail.BodyFormat = MailFormat.Html
AutoEmail.Body = "Ian" & ControlChars.CrLf & "Paul"
AutoEmail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "25")
System.Threading.Thread.Sleep(200)
SmtpMail.SmtpServer = "192.168.11.11"
System.Threading.Thread.Sleep(200)
SmtpMail.Send(AutoEmail)
End Sub
End Class
Re: How do I create a paragraph in an e-mail?
Did you try Johns "Environment.NewLine" or any othe variations
Re: How do I create a paragraph in an e-mail?
Hmmm.... Environment.NewLine does not work also. Can you give me more, what you call variations because I am a newbie at VB.NET.
The problem is when I open my e-mail at Yahoo the body of the e-mail says "Ian Paul" instead of "Ian <next line> Paul".
Re: How do I create a paragraph in an e-mail?
You've set your mail format as HTML so perhaps you need to use HTML tags. Try using <p> or <br> tags.
Re: How do I create a paragraph in an e-mail?
Quote:
Originally Posted by jmcilhinney
You've set your mail format as HTML so perhaps you need to use HTML tags. Try using <p> or <br> tags.
WOW!!!! It worked. Thanks man, you are the best.
Re: How do I create a paragraph in an e-mail?
*basking in admiring glow* :D
Cool. Don't forget to resolve your thread from the Thread Tools menu.
Re: How do I create a paragraph in an e-mail?