01.
<html>
02.
<head>
03.
<title>ThaiCreate.Com PHP & PowerPoint.Application</title>
04.
</head>
05.
<body>
06.
<?php
07.
08.
$ppApp
=
new
COM(
"PowerPoint.Application"
);
09.
$ppApp
->Visible = True;
10.
11.
$strPath
=
realpath
(
basename
(
getenv
(
$_SERVER
[
"SCRIPT_NAME"
])));
12.
13.
$ppName
=
"MySlides.ppt"
;
14.
$FileName
=
"MyPP"
;
15.
16.
17.
$ppApp
->Presentations->Open(
realpath
(
$ppName
));
18.
19.
20.
$ppApp
->ActivePresentation->SaveAs(
$strPath
.
"/"
.
$FileName
,17);
21.
22.
23.
$ppApp
->Quit;
24.
$ppApp
= null;
25.
26.
27.
28.
$strTo
=
"member@thaicreate.com"
;
29.
$strSubject
=
"PowerPoint Report"
;
30.
$strMessage
=
"PowerPoint Convert to JPG"
;
31.
32.
33.
$strSid
= md5(uniqid(time()));
34.
35.
$strHeader
=
""
;
36.
37.
$strHeader
.=
"From: Mr.Weerachai Nukitram<webmaster@thaicreate.com>\nReply-To: webmaster@thaicreate.com\n"
;
38.
$strHeader
.=
"Cc: Mr.Surachai Sirisart<surachai@thaicreate.com>"
;
39.
$strHeader
.=
"Bcc: webmaster@thaicreate.com"
;
40.
41.
$strHeader
.=
"MIME-Version: 1.0\n"
;
42.
$strHeader
.=
"Content-Type: multipart/mixed; boundary=\""
.
$strSid
.
"\"\n\n"
;
43.
$strHeader
.=
"This is a multi-part message in MIME format.\n"
;
44.
45.
$strHeader
.=
"--"
.
$strSid
.
"\n"
;
46.
$strHeader
.=
"Content-type: text/html; charset=windows-874\n"
;
47.
$strHeader
.=
"Content-Transfer-Encoding: 7bit\n\n"
;
48.
$strHeader
.=
$strMessage
.
"\n\n"
;
49.
50.
$objOpen
= opendir(
"MyPP"
);
51.
while
((
$file
= readdir(
$objOpen
)) !== false)
52.
{
53.
if
(
file_exists
(
"MyPP/"
.
$file
)
and
(
$file
!=
"."
and
$file
!=
".."
))
54.
{
55.
$strContent
=
chunk_split
(
base64_encode
(
file_get_contents
(
"MyPP/"
.
$file
)));
56.
$strHeader
.=
"--"
.
$strSid
.
"\n"
;
57.
$strHeader
.=
"Content-Type: application/octet-stream; name=\""
.
$file
.
"\"\n"
;
58.
$strHeader
.=
"Content-Transfer-Encoding: base64\n"
;
59.
$strHeader
.=
"Content-Disposition: attachment; filename=\""
.
$file
.
"\"\n\n"
;
60.
$strHeader
.=
$strContent
.
"\n\n"
;
61.
}
62.
63.
}
64.
65.
$flgSend
= @mail(
$strTo
,
$strSubject
,null,
$strHeader
);
66.
if
(
$flgSend
)
67.
{
68.
echo
"PowerPoint Created to Folder <b>MyPP</b> & Email Sending"
;
69.
}
70.
else
71.
{
72.
echo
"Email Can Not Send."
;
73.
}
74.
?>
75.
</body>
76.
</html>