1
我正在創建一個phonegap應用程序,用戶將捕獲一些圖片並將其附加到預定義的郵件ID。 Iam能夠捕捉圖像,但無法將所有圖片附加到應用程序文件夾中,即「/ mnt/sdcard/Android/data/pacakgename/cache /」。Phonegap - 動態郵件附件
我試圖執行動態附件中的this。
我的代碼如下所示:
<html>
<head>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8" src="emailcomposer.js"></script>
<script type="text/javascript">
document.addEventListener("deviceready", deviceready, true);
function deviceready() {
console.log("Device ready");
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, onFail);
}
function gotFS(fileSystem) {
var reader = fileSystem.root.createReader();
reader.readEntries(gotList, onFail);
}
function gotList(entries) {
var i;
var fullPath = "/mnt/sdcard/Android/data/packagename/cache/";
for (i=0; i<entries.length; i++) {
if (entries[i].name.indexOf(".jpg") != -1) {
console(entries[i].fullPath);
}
}
}
function composeText(){
var message1 = document.getElementById('message_body').value;
console.log(message1);
window.plugins.emailComposer.showEmailComposer(
"Get an Estimate",
message1,
["[email protected]"],
[],
[],
true,
[attachment link]
);
//exit the app after clicking this button
navigator.app.exitApp();
// navigator.camera.cleanup(onSuccess,fail);
// function onSuccess(){
// }
// function fail(){
// }
}
function onFail(message) {
alert('Failed because: ' + message);
}
</script>
<style type="text/css">
li{
list-style: none;
float:left;
padding: 0 5 5 0 ;
}
</style>
</head>
<body>
<h1>Get a Repair Estimate</h1>
<div style="clear:both;"></div>
Provide any details you want us to know(Optional):
<ul>
<li>
<textarea style="width:250px;height:250px;" name="message_body" id = 'message_body' placeholder="Add Notes here(if any)"></textarea>
</li>
<div style="clear:both;"></div>
<li>
<button onclick="composeText();">Get Your Estimate</button>
</li>
</body>
</html>
任何幫助。
這真的很棒git鏈接,現在它解決了我的附件文本文件問題,我可以附加文件併發送成功,謝謝@ sur007 –