in my Application i am using MFMailComposeViewController for emails...
I am Adding to Field in it programmaticly... I want To prevent user to edit the TO field,
User can't change TO field's email address... I am not able to find neither i know if it is possible or not
It is not necessary but still code is
NSArray *arr = [NSArray arrayWithObject:Emailstr];
MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setToRecipients:arr];
[controller
[controller setMessageBody:#"Hello there." isHTML:NO];
[self presentModalViewController:controller animated:YES];
It's not possible.
Related
I have write code to send mail on button click.But i have email id programatically.
I have output like this.
email#gmail.com Send MailButton
Now when i click on Send MailButton then it open MFMailComposeViewController but to field is empty.Here email#gmail.com is change dynamically it's not fixed.
My code is
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
if([MFMailComposeViewController canSendMail])
{
NSString *emailBody;
emailBody=self.shareString;
//NSLog(#"EMail Body ---- %#",emailBody);
[picker setMessageBody:emailBody isHTML:YES];
[picker becomeFirstResponder];
[self presentModalViewController:picker animated:YES];
}
What should be change here required?
Use following code:
NSArray *tempArray = [[NSArray alloc] initWithObjects:#"abc#gmail.com", nil];
[picker setToRecipients:tempArray];
It's working properly for me.
Thanks,
Hemang.
Well you need to create an array for this first.
-(void)displayComposerSheetEmailUs{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:#"Hello from the App!"];
// Set up recipients
NSArray *toRecipients = [NSArray arrayWithObject:#"abc#gmail.com"];
[picker setToRecipients:toRecipients];
// Fill out the email body text
NSString *emailBody = #"It is raining in sunny California!";
[picker setMessageBody:emailBody isHTML:NO];
[self presentModalViewController:picker animated:YES];
}
In my app i am pre-filling the email address when the user wants to email someone. i do this like this:
NSArray *toRecipients = [NSArray arrayWithObject:#"sales#microsmith.com"];
NSString *subjectStr = [[NSString alloc] initWithFormat:#"test subject"];
MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
mailController.mailComposeDelegate = self;
[mailController setToRecipients:toRecipients];
[mailController setSubject:subjectStr];
[self presentModalViewController:mailController animated:YES];
[mailController release];
[subjectStr release];
this all works fine with no problems. However, i wanted to know if there was a way to change what showed in the "To:" field once the email opens.
For example, instead of showing - sales#microsmith.com, i would like it to show "Microsmith Sales".
Is that possible?
thanks in advance
Yep, just change the way your recipient strings are formatted:
NSArray* recipients = [NSArray arrayWithObject: #"Sales Dept <sales#example.com>"];
I use MFMailComposeViewController canSendMail in my app everything works great but if there are no accounts on the iPhone or iPad it returns a standard alertview what I would like to change. If I put a alert in the else it will return 2 alerts. Is there a way to change the standard alert it returns? Or at least change the text in it?
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
if ([MFMailComposeViewController canSendMail]) {
controller.mailComposeDelegate = self;
controller.navigationBar.tintColor = [UIColor grayColor];
NSArray *toRecipients = [NSArray arrayWithObject:#"info#info.nl"];
[controller setToRecipients:toRecipients];
[controller setSubject:#"bericht van info"];
[self presentModalViewController:controller animated:YES];
[controller release];
}
else {
}
try one thing.. Move your MFMailComposeViewController initialization code inside the canSendMail block.
Move the alloc of the 'MFMailComposeViewController' inside the if:
if ([MFMailComposeViewController canSendMail]) {
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
controller.navigationBar.tintColor = [UIColor grayColor];
NSArray *toRecipients = [NSArray arrayWithObject:#"info#info.nl"];
[controller setToRecipients:toRecipients];
[controller setSubject:#"bericht van info"];
[self presentModalViewController:controller animated:YES];
[controller release];
} else {
// Display custom alert here.
}
You can check if the device can send emails with
[MFMailComposeViewController canSendMail]
And, if not, show the dialog in your side
I have a Mail Controller i had attached a image in mail controller
Now i want to add a text below this image.
I tried to set Message Body but text comes above image.
Next i tried to do and but it cant works.
I want to add text "Sent via Application Name"
Please Help
Thanks in Advance
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
controller.modalPresentationStyle = UIModalPresentationFullScreen;
[controller setSubject:#"App Name"];
controller.navigationBar.tintColor = [UIColor grayColor];
UIImage *img=dataObj.images;
NSData *imageData=UIImagePNGRepresentation(img);
[controller addAttachmentData:imageData mimeType:#"image/png" fileName:#"Default.png"];
NSString *abc=[NSString stringWithFormat:#"sent via App Name"];
[self presentModalViewController:controller animated:YES];
[controller release];
Do it this way:
NSString *abc=[NSString stringWithFormat:#"sent via App Name"];
[controller setMessageBody:abc isHTML:no];
I've configured a simple MFMailComposeViewController below. If I populate the setToRecipients, everything works fine, the email is sent. If I do not populate the setToRecipients, the mail composer window pops up but all fields remain non-editable.
I thought the MFMailComposeViewController would allow the user to edit the email before sending? Is this possible using the standard controls?
- (IBAction) sendEmail
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:[NSString stringWithFormat:#"Receipt Email - %#",[self.labelDate text]]];
NSString *emailBody = #"This is the message body";
[picker setMessageBody:emailBody isHTML:NO];
[self presentModalViewController:picker animated:YES];
[picker release];
}
Never mind guys.... I hadn't resigned first responder of the parent view >.< Resolved by adding [self.parentViewController resignFirstResponder]; [self becomeFirstResponder];