Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Emailing attachments
-
I'm trying to start composition of an email in the Mail App with a chosen attachment (an image chosen from the user's photos). There is a url scheme that goes like: mailto:emailaddress?body=BodyOfEmail?attachment=file, which I've been opening up in a WebView as an alternative, but while I've followed the conventions and advice I found in online forums, it doesn't seem to work with the iOS Mail App.
Three questions:
- has anybody had any success doing this in Pythonista this way? If so, is there any automated way to close the WebView once you've sent your email in the Mail App and switched back to Pythonista?
- Is there another API I'm missing in Pythonista that would allow us to do that? I've tried quicklook and open_in with the image, but that doesn't have the options I want.
- Finally, if it doesn't exist in 1.5, is this something that is already present in the 1.6 beta or will be added in the near future?
Ideally, I would like to have a sheet presented to the user, which sends the email, so that I don't have switch back and forth between Apps.
Any help greatly appreciated.
I really enjoy reading this forum periodically.
-
You don't need a webview, use
import webbrowser
webbrowser.open('mailto://')Sadly, apple doesn't allow the attachment to be sent via the url scheme, instead this would have to be done via api. You could always use smtplib to send your own email, though of course you'd need to get the users mail login, etc since you don't have access to the ios saved values.
-
Here is a basis of an email program, doesn't have the attachment feature, although could be easily implemented. You can use this if you are on Pythonista 1.5 - I'm working on a better version of this using the dialogs module in the Pythonista 1.6 beta.
-
Thanks for both of these suggestions. I generally prefer not to capture (or store) user credentials, but I may end up going with that solution (with SMTP) this time.