Jump to content


Photo

E-mailing html


  • Please log in to reply
5 replies to this topic

#1 eyegraphix

eyegraphix
  • Members
  • PipPip
  • Member
  • 24 posts
  • LocationAmes, Iowa

Posted 02 March 2006 - 08:58 PM

I'm e-mailing the contents of a form using the mail function. Some of the content e-mailed needs to be organized like in a table so that it looks nice when opened up. I tried doing this, but in the e-mail all I see is the html code. I know this must be easy, but, help?



#2 TronB24

TronB24
  • Members
  • PipPip
  • Member
  • 22 posts
  • LocationFlorida

Posted 02 March 2006 - 09:07 PM

Can you post the code?
...that depends on what the definition of "is" is.

#3 eyegraphix

eyegraphix
  • Members
  • PipPip
  • Member
  • 24 posts
  • LocationAmes, Iowa

Posted 02 March 2006 - 09:22 PM

Here's the mail content, what is sent off to the user.

$mailContent="Name:".$fname." ".$lname." "."sent the following preapplication materials \n\n"
           ."Name: ".$fname." ".$lname.": I am ".$gender."\n"
           ."Address: ".$address."\n"
           ."Telephone: ".$telephone."\n"
           ."E-mail: ".$email."\n"
           ."Country of Citizenship: ".$country."\n"
           ."Degree sought ".$degreesought."\n\n"

                       ."College of University \n"
                          ."Name and Location \n"
                       .$c1."\n"
                       ."Dates attended \n"
                       .$c1dts."\n"
                       ."Major \n"
                       .$clmj."\n"
                       ."Degree \n"
                       .$cldgre."\n"
                       ."Deg. Date \n"
                       .$clddt."\n"
                       ."GPA \n"
                       .$clgpa."\n\n"

                   ."College of University 2 \n"
                       ."Name and Location \n"
                       .$c2."\n"
                       ."Dates attended \n"
                       .$c2dts."\n"
                       ."Major \n"
                       .$c2mj."\n"
                       ."Degree \n"
                       .$c2dgre."\n"
                       ."Deg. Date \n"
                       .$c2ddt."\n"
                       ."GPA \n"
                       .$c2gpa."\n\n"

                       ."College of University 3 \n"
                       ."Name and Location \n"
                       .$c3."\n"
                       ."Dates attended \n"
                       .$c3dts."\n"
                       ."Major \n"
                       .$c3mj."\n"
                       ."Degree \n"
                       .$c3dgre."\n"
                       ."Deg. Date \n"
                       .$c3ddt."\n"
                       ."GPA \n"
                       .$c3gpa."\n\n"

                       ."
<html><table width='100%' border='0'>
  <tr>
    <td>Course Type </td>
    <td>Sem. 1 </td>
    <td>Sem. 2 </td>
  </tr>
  <tr>
    <td>General Chemistry </td>
    <td>".$gchem1."</td>
    <td>".$gchem2."</td>
  </tr>
  <tr>
    <td>Physical Chemistry </td>
    <td>".$pchem1."</td>
    <td>".$pchem2."</td>
  </tr>
  <tr>
    <td>Analytical Chemistry </td>
    <td>".$achem1."</td>
    <td>".$achem2."</td>
  </tr>
  <tr>
    <td>Biochemistry</td>
    <td>".$bchem1."</td>
    <td>".$bchem1."</td>
  </tr>
  <tr>
    <td>Organic Chemistry </td>
    <td>".$gchem1."</td>
    <td>".$gchem1."</td>
  </tr>
  <tr>
    <td>Physics</td>
    <td>".$phy1."</td>
    <td>".$phy2."</td>
  </tr>
  <tr>
    <td>Calculus</td>
    <td>".$calc1."</td>
    <td>".$calc2."</td>
  </tr>
  <tr>
    <td>Other Science </td>
    <td rowspan='2'>".$oscia1."</td>
    <td rowspan='2'>".$oscia2."</td>
  </tr>
  <tr>
    <td>".$oscia."</td>
  </tr>
  <tr>
    <td>Other Science </td>
    <td rowspan='2'>".$oscib1."</td>
    <td rowspan='2'>".$oscib2."</td>
  </tr>
  <tr>
    <td>".oscib."</td>
  </tr>
</table>
</body>
</html>
"."\n";


#4 willpower

willpower
  • Members
  • PipPipPip
  • Advanced Member
  • 296 posts
  • LocationWarrington, Cheshire, UK

Posted 02 March 2006 - 10:53 PM

see the recent posting on embedding images in mail....i have just posted the solution in there.

Will
Wait...I've got it...Bollocks, it's gone again!

If at first you don't succeed....stop using ASP and get onto PHP

#5 eyegraphix

eyegraphix
  • Members
  • PipPip
  • Member
  • 24 posts
  • LocationAmes, Iowa

Posted 03 March 2006 - 05:01 AM

Hey willpower, great code but the problem is that only part of $mailContent needs to be formatted in html. I suppose I could rewrite the whole $mailContent variable to be in html, but I really don't want to do that unless I have to. What I tried, was put all the content that needs to be html formatted in a variable called $html , then I just conctated that to the $mailContent variable. All the information is sent when e-mailed, but the content that's not html is not formatted right. Hope this makes sense. The relevant code is below.

$html=<<<HTML_OUTPUT
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />
<title>Untitled Document</title>
</head>
<body>
<table width='100%' border='0'>
  <tr>
    <td>General Chemistry </td>
    <td>".$gchem1."</td>
    <td>".$gchem2."</td>
  </tr>
  <tr>
    <td>Physical Chemistry </td>
    <td>".$pchem1."</td>
    <td>".$pchem1."</td>
  </tr>
  <tr>
    <td>Analytical Chemistry</td>
    <td>".$achem1."</td>
    <td>".$achem1."</td>
  </tr>
  <tr>
    <td>Biochemistry</td>
    <td>".$bchem1."</td>
    <td>".$bchem1."</td>
  </tr>
  <tr>
    <td>Organic Chemistry</td>
    <td>".$ochem1."</td>
    <td>".$ochem1."</td>
  </tr>
  <tr>
    <td>Physics</td>
    <td>".$phy1."</td>
    <td>".$phy2."</td>
  </tr>
  <tr>
    <td>Calculus</td>
    <td>".$calc1."</td>
    <td>".$calc2."</td>
  </tr>
  <tr>
    <td>Other Science </td>
    <td rowspan="2">".$oscia1."</td>
    <td rowspan="2">".$oscia2."</td>
  </tr>
  <tr>
    <td>".$oscia."</td>
  </tr>
  <tr>
    <td>Other Science </td>
    <td rowspan='2'>".$oscib1."</td>
    <td rowspan='2'>".$oscib2."</td>
  </tr>
  <tr>
    <td>".$oscib."</td>
  </tr>
</table>
</body>
</html>
HTML_OUTPUT;

$mailContent="Name:".$fname." ".$lname." "."sent the following preapplication materials \n\n"
           ."Name: ".$fname." ".$lname.": I am ".$gender."\n"
           ."Address: ".$address."\n"
           ."Telephone: ".$telephone."\n"
           ."E-mail: ".$email."\n"
           ."Country of Citizenship: ".$country."\n"
           ."Degree sought: ".$dgresot."\n\n"

                       ."College of University \n"
                          ."Name and Location: \n"
                       .$c1."\n"
                       ."Dates attended: \n"
                       .$c1dts."\n"
                       ."Major: \n"
                       .$c1mj."\n"
                       ."Degree: \n"
                       .$c1dgre."\n"
                       ."Deg. Date: \n"
                       .$c1ddt."\n"
                       ."GPA: \n"
                       .$c1gpa."\n\n"

                   ."College of University 2 \n"
                       ."Name and Location: \n"
                       .$c2."\n"
                       ."Dates attended: \n"
                       .$c2dts."\n"
                       ."Major: \n"
                       .$c2mj."\n"
                       ."Degree: \n"
                       .$c2dgre."\n"
                       ."Deg. Date: \n"
                       .$c2ddt."\n"
                       ."GPA: \n"
                       .$c2gpa."\n\n"

                       ."College of University 3 \n"
                       ."Name and Location: \n"
                       .$c3."\n"
                       ."Dates attended \n"
                       .$c3dts."\n"
                       ."Major: \n"
                       .$c3mj."\n"
                       ."Degree: \n"
                       .$c3dgre."\n"
                       ."Deg. Date: \n"
                       .$c3ddt."\n"
                       ."GPA: \n"
                       .$c3gpa."\n".
                       $html.

"GRE Scores \n".
"Verbal        ".$grev." ".$grevper."\n".
"Quant.        ".$grq." ".$greqper."\n".
"Analy.        ".$grea." ".$greaper."\n".
"Total        ".$total."\n".

"Subject GRE: Subject: ".$gresub."  Score: ".$gresubscore."   ".$gresubper."\n".
"TOEFL Score: ".$toefl."\n".
"Areas of Research interest: ".$interest."\n".
"Publications: ".$pubs."\n".
"Additional Information: ".$addinfo."\n".
"Server protocol: ".$remotehost."\n".
"Remote IP address: ".$ip."\n";
//End of $mailcontent

$headers = "From: xxx  \r\n";
$headers .="Reply-to: xxx  \r\n";
$headers .="MIME-Version: 1.0\r\n";
$boundary = uniqid ("something");
$headers .="Content-Type: multipart/alternative" . "; boundary = $boundary\r\n\r\n";
$headers .="This is a MIME encoded message. \r\n\r\n";
$headers .="--$boundary\r\n" . "Content-Type: text/plain; charset=ISO-8859-1\r\n" ."Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode("$textversion"));
$headers .="--$boundary\r\n" . "Content-Type: text/html; charset=ISO-8859-1\r\n" . "Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode("$mailContent"));


$email2="asiegrist@gmail.com";
$subject="Preapplication (Forms submission)";


if (!$lname) {
       echo "<b>Thank you</b> <br> You have not provided your last/family
name. All requested information must be submitted
       or we will not be able to properly process your preapplication";
       }
else {
    mail($email2, $subject, $mailContent, $headers);
    echo "Thank you for submitting a preapplication. Our graduate committee will review the materials and advise you of
their decision.";
    }


#6 helpmeplease2

helpmeplease2
  • Members
  • PipPipPip
  • Advanced Member
  • 87 posts

Posted 03 March 2006 - 05:26 AM

I can't get this to work. I'm using:

<?php 
$bar = <<<HTML_OUTPUT
<img src="http://www.site.com/images/picture.gif">
HTML_OUTPUT;
?>
<a href="javascript:addmsgtxt('Greetings,\n\n<?php $bar ?>')">Greetings</a><br>

I'm using javascript to insert the image into the <textarea> field, but its not including the code when it sends. What am I doing wrong? If I just type in the code into the textarea field and send it, it only displays the code in the email and not the picture I'm trying to insert.

I've tried sending html using my custom mailing list for the longest time, and everything I try fails.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users