|
|
|
อ่านไฟล์ excel ที่แนบไปกับเมลไม่ได้ บน smart phone แต่บน PC อ่านได้ปกติ |
|
|
|
|
|
|
|
รบกวนแนะนำด้วยครับ พอดีส่งเมลแนบไฟล์ excel file แต่ไม่สามารถอ่านไฟล์บน smart phone ได้ แต่ในเครื่อง PC อ่านได้ปกติ
ไม่แน่ใจว่าต้อง convert เป็นไฟล์อะไรอีกหรือป่าว
Code (PHP)
<?
//SEND MAIL //
$to = '[email protected]';
$from = '[email protected]';
$subject = 'MBC QC Report '.date('Ymd');
$message = 'Please review the following attachments.';
$attachments = "mbcqc_report".date("Ymd").".xls";
$headers = array('Reply-to' => '[email protected]','Some-Other-Header-Name' => 'Header Value');
$status = mailAttachments($to, $from, $subject, $message, $attachments, $headers);
if($status === True) {
print 'Successfully mailed!';
} else {
print 'Unable to send e-mail.';
}
?>
<?php
function mailAttachments($to, $from, $subject, $message, $attachments , $headers = array(), $additional_parameters = '') {
$headers['From'] = $from;
// Define the boundray we're going to use to separate our data with.
$mime_boundary = '==MIME_BOUNDARY_' . md5(time());
// Define attachment-specific headers
$headers['MIME-Version'] = '1.0';
$headers['Content-Type'] = 'multipart/mixed; boundary="' . $mime_boundary . '"';
// Convert the array of header data into a single string.
$headers_string = '';
foreach($headers as $header_name => $header_value) {
if(!empty($headers_string)) {
$headers_string .= "\r\n";
}
$headers_string .= $header_name . ': ' . $header_value;
}
// Message Body
$message_string = '--' . $mime_boundary;
$message_string .= "\r\n";
$message_string .= 'Content-Type: text/plain; charset="iso-8859-1"';
$message_string .= "\r\n";
$message_string .= 'Content-Transfer-Encoding: 7bit';
$message_string .= "\r\n";
$message_string .= "\r\n";
$message_string .= $message;
$message_string .= "\r\n";
$message_string .= "\r\n";
// Add attachments to message body
$local_filename = "C:\Apache2.2\htdocs\mail\mbc_temp\mbcqc_report".date("Ymd").".xls";
if(is_file($local_filename)) {
$message_string .= '--' . $mime_boundary;
$message_string .= "\r\n";
$message_string .= 'Content-Type: application/octet-stream; name="' . $attachments . '"';
$message_string .= "\r\n";
$message_string .= 'Content-Description: ' . $attachments;
$message_string .= "\r\n";
$fp = @fopen($local_filename, 'rb'); // Create pointer to file
$file_size = filesize($local_filename); // Read size of file
$data = @fread($fp, $file_size); // Read file contents
$data = chunk_split(base64_encode($data)); // Encode file contents for plain text sending
$message_string .= 'Content-Disposition: attachment; filename="' . $attachments . '"; size=' . $file_size. ';';
$message_string .= "\r\n";
$message_string .= 'Content-Transfer-Encoding: base64';
$message_string .= "\r\n\r\n";
$message_string .= $data;
$message_string .= "\r\n\r\n";
}
// Signal end of message
$message_string .= '--' . $mime_boundary . '--';
// Send the e-mail.
return mail($to, $subject, $message_string, $headers_string, $additional_parameters);
}
?>
Tag : PHP, Oracle, Excel (Excel.Application), iOS, iPhone, Windows
|
|
|
|
|
|
Date :
2014-03-24 10:48:47 |
By :
xmen |
View :
732 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
บนสมาร์ทโฟนมีตัวอ่าน Excel หรือเปล่า??
|
|
|
|
|
Date :
2014-03-24 11:55:35 |
By :
apisitp |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มีครับ ไฟล์อื่นลองก้อบเข้าไปตรงๆอ่านได้ครับ
|
|
|
|
|
Date :
2014-03-24 12:23:28 |
By :
xmen |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|