<html> <head> <title>ThaiCreate.Com PHP & PowerPoint.Application</title> </head> <body> <?php $ppApp = new COM("PowerPoint.Application"); $ppApp->Visible = True; $strPath = realpath(basename(getenv($_SERVER["SCRIPT_NAME"]))); // C:/AppServ/www/myphp $ppName = "MySlides.ppt"; $FileName = "MyPP"; //*** Open Document ***// $ppApp->Presentations->Open(realpath($ppName)); //*** Save Document ***// $ppApp->ActivePresentation->SaveAs($strPath."/".$FileName,17); //'*** 18=PNG, 19=BMP **' //$ppApp->ActivePresentation->SaveAs(realpath($FileName),17); $ppApp->Quit; $ppApp = null; //*************** Send Email ***************// $strTo = "[email protected]"; $strSubject = "PowerPoint Report"; $strMessage = "PowerPoint Convert to JPG"; //*** Uniqid Session ***// $strSid = md5(uniqid(time())); $strHeader = ""; $strHeader .= "From: Mr.Weerachai Nukitram<[email protected]>\nReply-To: [email protected]\n"; $strHeader .= "Cc: Mr.Surachai Sirisart<[email protected]>"; $strHeader .= "Bcc: [email protected]"; $strHeader .= "MIME-Version: 1.0\n"; $strHeader .= "Content-Type: multipart/mixed; boundary=\"".$strSid."\"\n\n"; $strHeader .= "This is a multi-part message in MIME format.\n"; $strHeader .= "--".$strSid."\n"; $strHeader .= "Content-type: text/html; charset=windows-874\n"; // or UTF-8 // $strHeader .= "Content-Transfer-Encoding: 7bit\n\n"; $strHeader .= $strMessage."\n\n"; $objOpen = opendir("MyPP"); while (($file = readdir($objOpen)) !== false) { if(file_exists("MyPP/".$file) and ($file != "." and $file != "..")) { $strContent = chunk_split(base64_encode(file_get_contents("MyPP/".$file))); $strHeader .= "--".$strSid."\n"; $strHeader .= "Content-Type: application/octet-stream; name=\"".$file."\"\n"; $strHeader .= "Content-Transfer-Encoding: base64\n"; $strHeader .= "Content-Disposition: attachment; filename=\"".$file."\"\n\n"; $strHeader .= $strContent."\n\n"; } } $flgSend = @mail($strTo,$strSubject,null,$strHeader); // @ = No Show Error // if($flgSend) { echo "PowerPoint Created to Folder <b>MyPP</b> & Email Sending"; } else { echo "Email Can Not Send."; } ?> </body> </html>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท