katzer / cordova-plugin-email-composer

Edit and send email messages
Apache License 2.0
344 stars 334 forks source link

can't get predefined email opened, empty draft works. #80

Closed TomAngel closed 9 years ago

TomAngel commented 9 years ago

Hi, I tried around but I didn't find a solution at all. I coded an app in Dreamwerver with connection to Adobe Phonegap Build. This app is for documentations of emergency call related works for my workplace.

My config.xml:

My config.xml:

<gap:plugin name="de.appplant.cordova.plugin.email-composer" version="0.8.1" />
<gap:plugin name="org.apache.cordova.camera" version="0.3.2" />

My <script> :

document.addEventListener('deviceready', function () {
    // cordova.plugins.email is now available
}, false);

window.plugin.email.isServiceAvailable(
    function (isAvailable) {
        // alert('Service is not available') unless isAvailable
    }
);

var htmbody = "<h1><strong>Protokoll Rufbereitschaftseinsatz vom " + $("#datum-einsatz") + 
    "</h1><br><br>Name Rufbereitschaft :  </strong>" + $("#name-rb").text() + 
    "<br><strong>Name Leitstand :   </strong>" + $("#name-warte").text() +
    "<br><strong>Meldezeitpunkt :   </strong>" + $("#zeit-meldung").val() + $("#datum-einsatz") +
    "<br><strong>Einsatzort :   </strong>" + $("#einsatzort").text() +
    "<br><br><strong>Situationsbeschreibung :  </strong>" + $("#textarea-situation").text() +
    "<br><strong>Foto :      </strong>" + $("#largeImage") +
    "<br><br><strong>Ausgeführte Arbeiten :    </strong>" + $("#textarea-massnahmen").text() +
    "<br><strong>Änderungen der Fahrweise im Leitstand :    </strong>" + $("#textarea-fahrweise").text() +
    "<br><strong>Störungsstatus nach Einsatz :     " + $("#behoben option:selected").text() +
    "<br>Ende des einsatzes um </strong>" + $("#zeit-ende").text() +
    "<br><br><strong>Kopie an Abteilung </strong>" + $("#email-abteilung").text() +
    "<br><h2>Ende der Nachricht</h2><br><hr><br>";

window.plugin.email.open({
    to:         ['le...d@wahnbach.de'],
    cc:         [$("#abteilung-mail").val()], //Variable für ausgewählten Meister/Abteilung Sammelmail einrichten von EDV
    subject:        "Protokoll RB-Einstatz "+ $("#datum-einsatz"), // +Einsatzdatum und -zeit
    attachments:    [$("#largeImage.src")],
    body:       htmbody, // HTML Nachricht + Formulardaten
    isHtml:     true
});

window.plugin.email.open(properties, function () {
    console.log('email view dismissed');
}, this);

(E-Mail to:  blanked due to publishing)

And my Button for Function call:

<button onClick="window.plugin.email.open();" data-inline="true"><strong>Senden und abschließen</strong></button>

On Button press, Android App-Selector pops up to select Mail-App. Every single Email-App opens an empty draft, none shows any of my predefinitions. Can someone help please, I have no intend what's wrong... Please...

TomAngel commented 9 years ago

Solved, I put the script content into a function. Now it works...