views:

608

answers:

1

Hi,

I have used this code from link below to send excel file as attachment.

http://www.hotscripts.com/forums/php/22626-php-form-excel-then-send-email-attachment.html

Here is the code I have used:

    <?php 
ob_start(); 
?> 
<html> 
<head><title></title> 
</head> 
<body> 
<body> 
<center> 
<table> 
 <tr>
   <td>Name:</td><td>My Name</td>  
 </tr>
 <tr>
   <td>Address:</td><td>My address</td>
 </tr>
 <tr>
   <td>Gender:</td><td>Female</td>
 </tr>
</table> 

</body></html> 

<?php 
$FILE_CONTENTS = ob_get_contents(); 
ob_clean(); 
// include the class 
include("../includes/classes/class.mailer.php");
$recipient = "[email protected]"; 


$from = "[email protected]"; 

// subject 
$subject = "Subject of email"; 
// email message 
$message = " 
Here goes the message.
            "; 
$myEmail = new EPDEV_Emailer($recipient, $from, $subject); 
$myEmail->addText($message); 
$myEmail->addFile("my.xls", "application/vnd.ms-excel", $FILE_CONTENTS); 
$myEmail->send(); 
?>

I get excel file in mail but the file does not contain the lines as the normal excel file contains. But i need the file with lines as excel file contains. Can anyone suggest me what the problem might be.

Thanks in advance

+1  A: 

I think that you should split your problem in two:

  1. Do you have problems with reading other file types? Try to send a text file and a JPG and see if you have problems reading them as well.
  2. Are you sure the Excel files are OK? Try to save them locally on server, then download by FTP and try to open.

I would guess that the problem is in generating the Excel files (2.), not with sending them by email (1.). But that's just a guess.

warpech
I did as u said. I can get proper excel file. The file contains all the contents i need. The only problem is the excel file does have lines in it. Hope you got it. Thanks warpech