I was working for a mail app using MFMailComposeViewController.
web page was loaded when user cliks on a button.
i set recipients sender, cc to the mail.
i attach one image to the body of email using follow code:
[mailpage setToRecipients:toRecipients];
[mailpage setCcRecipients:ccRecipients];
[mailpage setBccRecipients:bccRecipients];
// Attach an image to the email
NSString *path = [[NSBundle mainBundle] pathForResource:#"iCon" ofType:#"png"];
NSData *myData = [NSData dataWithContentsOfFile:path];
[mailpage addAttachmentData:myData mimeType:#"image/png" fileName:#"iCon"];
Now i want to attach the table view which was already in my view to the body of the email page.
help me..
Thanks in advance
AFAIK it's not possible to add UITableView to email. You have two options, first - generate html, and content of table view as html table, or second - render content of this UITableView in PDF file, and next add this pdf to email.
Related
Im trying attach a UI webview to the email body in my project. I have a combination of text fields and ui webview. When I try to attach the UI WebView the text boxes ok appear but the the uiwebview contents do not.
NSString *emailBody = [NSString stringWithFormat:#"%#%#",textfieled.text,webview.tag];
[mail setMessageBody:emailBody isHTML:YES];
I realise the .tag might be incorrect on the webview, could someone tell me what i should be putting there (or doing wrong)as I have tried all combinations available?
How can I send the information that the user inset in text field UITextField to my email?
and how can I let the information page shows once, only at the first time the user enters the app?
What you're asking is vague, but to take the data entered into a textfield and put it in a string just use:
NSString *theEmailBody = theTextField.text;
From there you can send an email using the standard Apple email framework:
MFMailComposeViewController *mail =[[MFMailComposeViewController alloc] init];
NSString *theEmailbody = theTextField.text;;
[mail setMessageBody:theEmailbody isHTML:NO];
or by making your own mail server and sending the HTTP request there.
You can use the following code in you function to send email.
MFMailComposeViewController *mail =[[MFMailComposeViewController alloc] init];
NSString *emailbody = textField.text;;
[mail setMessageBody:emailbody isHTML:NO];
Apple has sample code to show you how to set up in app email (linked below)
After you've done this, you can easily change (for example) the body of your email to be the contents of your textField by adding this where appropriate.
NSString *emailBody = myTextField.text;
Then additionally, if you wish for the information page to only be visible the first time the app is launched, look into NSUserDefaults. This will allow you to store and retrieve a value to let the app know wether or not to load your information page.
https://developer.apple.com/library/ios/#samplecode/MailComposer/Introduction/Intro.html#//apple_ref/doc/uid/DTS40008865
I am implementing an iphone application (iOS 4.2) from where I would like to trigger the email client to send messages with attachments. I could effectively use uri schemes in combination with the class NSURL in order to trigger the email app but I was wondering whether it is possible to attach images. I have tried with mailto:whoever#wherever.org?subject=sthg&body=sthgelse&attachment=/path/to/file but the attachments are not included. I know iphone applications are sandboxed therefore it is possible that the email utility were not able to access the path to my image since it is located in my application bundle. On the other hand I was considering to administer my images with the photo manager. (1) Is there a way to include attachments in this way? (2) If so, is it possible to reference images either from my app or from the photo client? I could not find any attachments argument in the mailto RFC but maybe Apple has provided some way to achieve this.
Thanks in advance for your help,
Luis
MFMailComposeViewController will be able to do that, some example of usage belows:
remember to add MessageUI.framework
MFMailComposeViewController *email = [[MFMailComposeViewController alloc] init];
email.mailComposeDelegate = self;
[email setSubject:#"Whatever"];
// Set up recipients
NSArray recipients = [NSArray arrayWithObject:#"whoever#wherever.org"];
[email setToRecipients:recipients];
// Attach an image to the email
UIImage *attachment = ...;
NSData *data = UIImagePNGRepresentation(attachment);
[email addAttachmentData:myData mimeType:#"image/png" fileName:#"ok.png"];
// Fill out the email body text
NSString *emailBody = #"test mail";
[email setMessageBody:emailBody isHTML:NO];
[self presentModalViewController:picker animated:YES];
[email release];
Instead of using the mailto: URL scheme, you should use the MFMailComposeViewController which allows you to add attachments. It also has the added benefit that using will not leave your app.
If one does not have account MFMailComposeViewController simply crashes.
Yes, you can call canSendMail first with the result NO(!), what next?
The answer is - use 'mailto:'. It'll popup dialog to create account.
Currently, I can set a button to take a picture, but I'm unsure how to pass this as an attachment for an email in the same view.
The view is for a quote and allows the user to enter data into a few fields then has a button to email said data.
Maybe this link would satisfy your requirement for the second half of the question...
http://www.ericd.net/2009/04/sending-email-from-iphone-application.html
UIImage *myImage = [UIImage imageNamed:#"mobiletuts-logo.png"];
NSData *imageData = UIImagePNGRepresentation(myImage);
[mailer addAttachmentData:imageData mimeType:#"image/png" fileName:#"mobiletutsImage"];
Courtesy:
http://mobile.tutsplus.com/tutorials/iphone/mfmailcomposeviewcontroller/
Check out Apple's MailComposer example http://developer.apple.com/library/ios/#samplecode/MailComposer/Introduction/Intro.html#//apple_ref/doc/uid/DTS40008865
There have been some older posts about this with very complicated answers. I was wonder if there is a simple way to take an image that is in your project and put it in an email, composed your app but sent through the mail program.
I also don't know how to format it. If I put \n the mail program is never opened.
Here is what does work:
NSString *url = [NSString stringWithString: #"mailto:?&subject=Hello%20There!&body=Really%20Cool.%20Check%20this%20out!"];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: url]];
And I would like to add an image and make it look nice, with newlines. Could someone help me out here?
Thanks!
R
You have two options, image as attachment with a mail compose view, or inline as HTML, which means you'd have to upload the app's images somewhere accessible with a permalink or fixed URL. Even if you can form a URL with a local path, the email recipient doesn't receive mail using your app, so it's sandboxed away from the world.
If you generate the pictures in the app it's not easier than a mail compose view, but if uploading them is okay it's dead easy.
I solved it today by uploading optimized and smaller jpg versions of the png images with FTP and linking to it with <b><img src="http://blah.etc.org/myfolder/mypic.jpg" /></b>. The <b> tags were needed to "trick" openURL into not stripping the image back in SDK 3.0, they might not be needed now.
You will want to use MFMailComposeViewController to send an attachment.
Attach an image that is part of your app (in the same directory) to an email like this:
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:#"My Image Is Attached"];
//other mail settings here
//now add your attachment
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *whereToFindFile = [NSString stringWithFormat:#"myImage.png"];
NSString *appFile = [documentsDirectory stringByAppendingPathComponent:whereToFindFile];
NSData *imageData1 = [[[NSData alloc] initWithContentsOfFile:appFile] autorelease];
[picker addAttachmentData:imageData1 mimeType:#"image/png" fileName:#"myImage"];