Table in a HTML mail

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • webandwe
    New Member
    • Oct 2006
    • 142

    Table in a HTML mail

    Hi,

    I'm trying to send a table in my e-mail but having problems with the " and '

    I don't know ASP so please tel mehow do I fix this probles.

    here is what I want to do (piece of the code), The problem is with the width and border's " ".

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

    Code:
    myMail.HTMLBody = "<table width="400" border="1">
      <tr>
        <td>sample text</td>
        <td>sample text</td>
      </tr>
      <tr>
        <td>sample text</td>
        <td>sample text</td>
      </tr>
    </table>"
    Last edited by DrBunchman; Sep 11 '08, 07:47 AM. Reason: Added [Code] Tags - Please use the '#' button
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi webandwe,

    Inside a string (which is delimited by double quotes) you can use single quotes to mark the beginning and end of html properties. Also, it is easier to build your html body as a string variable and then assign that to the mail object property.

    Here's an example using your code above:

    Code:
    Dim sBody
    sBody = "<table width='400' border='1'>"
    sBody = sBody & "<tr>"
    sBody = sBody & "<td>sample text</td>"
    sBody = sBody & "<td>sample text</td>"
    sBody = sBody & "</tr>"
    sBody = sBody & "</table>"
    
    myMail.HTMLBody =  sBody
    Does this make sense? Let me know,

    Dr B

    Comment

    • omerbutt
      Contributor
      • Nov 2006
      • 638

      #3
      Originally posted by DrBunchman
      Hi webandwe,

      Inside a string (which is delimited by double quotes) you can use single quotes to mark the beginning and end of html properties. Also, it is easier to build your html body as a string variable and then assign that to the mail object property.

      Here's an example using your code above:

      Code:
      Dim sBody
      sBody = "<table width='400' border='1'>"
      sBody = sBody & "<tr>"
      sBody = sBody & "<td>sample text</td>"
      sBody = sBody & "<td>sample text</td>"
      sBody = sBody & "</tr>"
      sBody = sBody & "</table>"
      
      myMail.HTMLBody =  sBody
      Does this make sense? Let me know,

      Dr B
      of course you should use this technique to concatinate the table into the mail body ....this is the more managed and precised method any one can tell what the code is doing by just a glimpse of it.

      Comment

      • webandwe
        New Member
        • Oct 2006
        • 142

        #4
        Hi,

        Thanks I'll do it that way. In PHP I created the table, paste and swap the ' " around.

        The reason I ask was because I have one huge form. 101 fields. (really 101).

        Thanks all.

        Comment

        • omerbutt
          Contributor
          • Nov 2006
          • 638

          #5
          Originally posted by webandwe
          Hi,

          Thanks I'll do it that way. In PHP I created the table, paste and swap the ' " around.

          The reason I ask was because I have one huge form. 101 fields. (really 101).

          Thanks all.
          sure webandwe,
          you are welcome any time :)
          regards,
          Omer Aslam

          Comment

          Working...