Results 1 to 2 of 2

Thread: Question about Email body in my asp.net

Hybrid View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2004
    Posts
    24

    Question about Email body in my asp.net

    Hi experts,

    My asp.net application will send an email to our marketing department when a user filled out the application.
    In my strBody of the following code, it will list all 6 strCheckBoxs (string value) from my application. If
    However, how to write the lines that only when strCheckBoxs is not an empty string? I mean, skip the line if the strCheckBox is an empty string ""???

    Can I use IF--ELSE statement somewhere in this code to eliminate the rows which contains empty string strCheckBox????

    Thank you.
    --------------------------------------------------------------------------

    Dim msgFax As MailMessage = New MailMessage
    msgFax.To = "name@domain"
    msgFax.From = "webmaster@domain"
    msgFax.Subject = "PRIMARY SCHOOL APPLICATION"
    msgFax.BodyFormat = MailFormat.Html

    Dim strBody As String
    strBody = "<h3>BK and PRIMARY SCHOOL </h3>" + "<br>" + _
    " __________________________________________________ ________" + "<br>" + _
    "
    "- CERTIFICATE OF ACHIEVEMENT - " + "<br>" + _
    " * " & strCheckBox1 + "<br>" + _
    " * " & strCheckBox2 + "<br>" + _
    " * " & strCheckBox3 + "<br>" + _
    " * " & strCheckBox4 + "<br>" + _
    " * " & strCheckBox5 + "<br>" + _
    " * " & strCheckBox6 + "<br>" + _
    " * Comments : &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" & txtComment.Text + "<br>"

    msgFax.Body = strBody
    SmtpMail.SmtpServer = "server.companyname.com"
    SmtpMail.Send(msgFax)

  2. #2
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: Question about Email body in my asp.net

    VB Code:
    1. Private Function CreateBody() As String
    2.         Dim strBody As String = "<h3>BK and PRIMARY SCHOOL </h3>" & "<br>" & _
    3.         " __________________________________________________ ________" & "<br>" & _
    4.         "- CERTIFICATE OF ACHIEVEMENT - " + "<br>"
    5.         If CheckBox1.Checked = True Then strBody &= " * " & strCheckBox1 + "<br>"
    6.         If CheckBox2.Checked = True Then strBody &= " * " & strCheckBox2 + "<br>"
    7.         If CheckBox3.Checked = True Then strBody &= " * " & strCheckBox3 + "<br>"
    8.         If CheckBox4.Checked = True Then strBody &= " * " & strCheckBox4 + "<br>"
    9.         If CheckBox5.Checked = True Then strBody &= " * " & strCheckBox5 + "<br>"
    10.         If CheckBox6.Checked = True Then strBody &= " * " & strCheckBox6 + "<br>"
    11.         strBody &= " * Comments : &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" & txtComment.Text & "<br>"
    12.         Return strBody
    13.     End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width