Jason, looking back at your project file, I see that you do have addAttachement.
I knew that you were trying to use MFMailComposeViewController. Others were trying to add an attachment to mailto url scheme.
Sorry not to notice that you already had attachment in your project. I do appreciate the contributions that all are making in extending the capabilities of Xojo iOS.
Hi, When I played with Jason’s bit of code, i just get the message ‘Email not available’ even though i have email set up on my device - I am currently testing on an iPod as I dont have an iPhone, only androids - but if there is a way of using the htmlviewer to also do the attachment then I could program around it.
Yes it appears that there may be a bug in iOS 8 where canSendMail returns false even when mail is setup so I don’t think the built in class from apple will work…
There may be a workaround using a web service and httpsocket. But that requires creating the web service that will receive all elements of the message (to, from, subject, body, attachments), and send that from the web app. It is not that difficult to do with Web Edition, but that does require having a web host.
Exactly, the beauty of the apple method is that it caches the email to the user’s outbox so that it can be created without an internet connection and actually delivered when one is/becomes present. I also wonder if an app could be rejected because it does not use the MessageUI API and instead employs an httpsocket. I wouldn’t doubt it if a reviewer decided to reject an app for that. Unfortunately the apple method does not work for now so I’m not sure what to say.
I just tried the mailto: approach and it neither works in HTMLViewer nor with ShowURL. So that leaves very few possibilities. If the documented method does not work, the minimum is to look for alternatives.
I have seen on the Internet smtp OC classes for iOS as well, so chances are some apps in iTunes Store already use that. Actually, there are several apps doing it (searched for ‘smtp’). So seems to me reviewers had to approve them at some point. Now the challenge will be to implement smtp through declares or something else.
Technically, using httpsocket to use a web service is no different than using a mail form on a site in Safari. I do not see why reviewers should frown. But they have proven in the MAS they have ample stocks of stupidity left. …
Proof is in the pudding… But at one point, the dozen or so apps using what appears to be web APIs to manage email should not have been accepted. Starting with Yahoo and Google mail…
I am completing an app in which I use an HTMLViewer to display a short help/manual about it. I just added the possibility to send email through a web app hosted on my site. After spending a while designing an iOS app, I was sensitized to the particulars of the iOS 8 design, so I made the screen as close as I could to the native interface, made sure I managed rotation elegantly, created webpages for iPhone and iPad so they be real nice.
Apart from a small lag when the app starts, the look and feel of the mail form app is real close to a native page.
That would not resolve the possibility to send an attachment, but for simply allowing users to communicate, I am convinced it will be great.
Until we can figure out why canSendMail always returns false, you won’t be able to send emails anyway. But the fix for that crash is to remove the “alloc” from this line in NSDataFromFolderitem:
dim NSDataRef as ptr = dataWithContentsOfFile(alloc(NSClassFromString("NSData")), f.Path)
So it should be:
dim NSDataRef as ptr = dataWithContentsOfFile(NSClassFromString("NSData"), f.Path)
Right, since you can’t send mail an exception is thrown and your app is killed by the OS. The note from the docs on canSendMail:
Discussion
You should call this method before attempting to display the mail composition interface. If it returns NO, you must not display the mail composition interface.