EddyVerbruggen / nativescript-email

:envelope: NativeScript plugin for opening draft e-mails
MIT License
47 stars 15 forks source link

Attaching PDFs #36

Open sroy93 opened 5 years ago

sroy93 commented 5 years ago

Does attaching PDFs work with this plugin? I am getting a 'File not Found' error for the remote URL path to the PDF, but it is the correct path and is accessible when the URL is plugged into a browser.

Thanks!

EddyVerbruggen commented 5 years ago

Can you show the actual code?

sroy93 commented 5 years ago

Sure. Here's the piece of it that contains the email portion: (See below the code for the value of the attachment path variable)

email.available().then((avail: boolean) => { if(avail) { dialogs.prompt({ title: "Enter Email", message: "Please enter the address you want to send the document to below", okButtonText: "Send", cancelButtonText: "Cancel", inputType: dialogs.inputType.email }).then((r) => { if(r.result = true) { if(r.text != "") { email.compose({ subject: "CPU Signed Form - " + this.cpuOrder.OrderNumber, body: "See attachment.", to: [r.text], attachments: [ { fileName: this.cpuOrder.OrderNumber + '-SIG.pdf', path: this.pdfPath, mimeType: 'application/pdf' }] }).then( function() { console.log("Email composer closed"); }, function(err) { dialogs.alert({ title: "Email Not Sent" ,message: "Error: " + err ,okButtonText: "Ok" });
}); } else { dialogs.alert({ title: "Enter a Valid Email" ,message: "Please enter an email address" ,okButtonText: "Ok" });
} } })

                }
                else {
                    dialogs.alert({
                        title: "Email Not Supported"
                        ,message: "This device does not support OR is not set up for emailing."
                        ,okButtonText: "Ok"
                    });
                }

The error reads: "File not found for path: http://cpuimages.ivansmith.com/CPUImages/SignaturePDFs/1001903LG28-SIG.pdf"

So that is going to be the value of the variable in the code.

EddyVerbruggen commented 5 years ago

Quite frankly, I can't access that file either:

Screenshot 2019-11-06 at 20 59 12
sroy93 commented 5 years ago

Well you aren't going to be able to if you aren't on the correct network. I can though from a browser.

sroy93 commented 5 years ago

I am also displaying the PDF via another NativeScript plugin using the same variable, so the same URL. So it is not as though the app itself cannot access it.

EddyVerbruggen commented 5 years ago

Let’s not complicate things. Do you have the same issue with a publicly available pdf (please post an example)

sroy93 commented 5 years ago

Good thought. I tried replacing the variable in my code with the public URL you find here. It gives the same error.

email.available().then((avail: boolean) => { if(avail) { dialogs.prompt({ title: "Enter Email", message: "Please enter the address you want to send the document to below", okButtonText: "Send", cancelButtonText: "Cancel", inputType: dialogs.inputType.email }).then((r) => { if(r.result = true) { if(r.text != "") { email.compose({ subject: "CPU Signed Form - " + this.cpuOrder.OrderNumber, body: "See attachment.", to: [r.text], attachments: [ { fileName: this.cpuOrder.OrderNumber + '-SIG.pdf', path: "https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf", mimeType: 'application/pdf' }] }).then( function() { console.log("Email composer closed"); }, function(err) { dialogs.alert({ title: "Email Not Sent" ,message: "Error: " + err ,okButtonText: "Ok" });
}); } else { dialogs.alert({ title: "Enter a Valid Email" ,message: "Please enter an email address" ,okButtonText: "Ok" });
} } })

                }
                else {
                    dialogs.alert({
                        title: "Email Not Supported"
                        ,message: "This device does not support OR is not set up for emailing."
                        ,okButtonText: "Ok"
                    });
                }
            })
sroy93 commented 4 years ago

Is there any update on this by chance? I have now tested this on an Android, as well as, iOS and the issue occurs on both.

EddyVerbruggen commented 4 years ago

I have not found time to look into it. Flagging it as "help wanted" so perhaps someone else can step in.