email in iOS

Awesome work Jason!!!

Thanks!

.canSendMail is still returning false on my iPod Touch even though I am able to send mail using the iOS Mail app…

Any suggestions on how I can figure out what is going wrong?

Thanks

Hi James, is this the example project, or your own where you copied the class? If its the example that is weird because I deployed it to my phone and everything worked… If it is your own project make sure that you include the

Extensions.LoadFramework("MessageUI")
method call in the app open event, or yes, it still won’t work. The more info you can provide the more likely I can figure out what is wrong.

Thank you Jason!

It was my own project and you nailed the problem… I had not included: Extensions.LoadFramework(“MessageUI”). It now works.

Thanks again.

You’re welcome!

I’m using the routine, but if I try and second email, the second email doesn’t send, or even disappear from the screen.

Should there be something at the end of the email routines to check that the email has sent, and reset the routines or something?

You can see the same problem with the example app.

Hmm interesting, I see what you mean. If you recreate the object before showing it again it works as expected. I’ll have to look into this some more. Unfortunately I have an event this weekend so I’m not sure when I’ll finally be able to look into it.

The same thing happened with the UIImagePickerViewController (Camera) class. I solved that with a wrapper class which recreated the view controller when it was dismissed. I will probably end up doing the same thing here.

Thanks for the reply. I’m glad it’s not something stupid I’ve missed. The move from using Xojo/Real for Mac to iOS is proving more challenging than I thought it would be.

Yeah, iOS is definitely a different beast. I haven’t tested it but I think you might be able to create the MFMailComposeViewController directly in code every time you need to send an email, in which case it should work every time. If you try it please post back what you find.

Edit: Quickly looking through some sample code online it looks like you are definitely supposed to recreate it each time and not reuse the object so that could explain the weird behavior. I’ll plan to change the example code in iOSKit (should have a new version to commit soon with some new classes :slight_smile: )

Quick check in the emulator, and

dim mymail as new Extensions.MFMailComposeViewController

Does seem to work. Multiple emails can be created, dismissed etc. I’ll check it for real on my iPhone when I get home tonight.

Ok, got home, built app with version above, and it now seems to be working correctly for the few test runs I’ve done. Thanks, Jason!

Great. I’ll update the example in iOSKit accordingly.

I know this is an old thread, but I tried building Jason’s project and I get the error while building:

ld: framework not found framework

Does anyone know what that might be?

Hi James,
Which project? Please download the latest version of iOSKit from Github and try again.

Jason

I downloaded the project from your last link above. I will go to Github and try from there.

Thanks Jason

You’re welcome. There have definitely been some changes since the above link was posted, so you shouldn’t have that problem anymore.

Hi Jason,

That worked great … thank you very much. I just have one last question. How do you get the contents of a TextField into the message field of the email? This works when you have a string.

mailComposeView.setMessage "Hello World"

But you can’t do this

mailComposeView.setMessage=txtMessage.Text

In the TextField I have paragraphs I would like preserve and I would like the email to format the same way the TextField is formatted. There is nothing fancy just blank lines between paragraphs.

I tried this code:

Dim MES as Text MES=txtMessage.Text mailComposeView.setMessage MES

This code puts the text into the email, but all the text runs together and there is no longer blank lines between the paragraphs.

Do you know how to put the contents of the TextField into the email message so it still preserves the line breaks?

Never mind Jason. I figured it out. I was using &uOD for the line breaks. I should have been using &uOA instead. It formats correctly now. Thanks so much for your help. I really appreciate it.