Click here to Skip to main content
15,793,845 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
This is code. Code exectues properly but i am not receiving mail in inbox...

i have also set MFMailComposeViewControllerDelegate in interface

- (IBAction)SendMailButton:(id)sender

if ([MFMailComposeViewController canSendMail])
MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];

mailer.mailComposeDelegate = self;

[mailer setSubject:[NSString stringWithFormat:@"Ordered Products & Person Details"]];

NSArray *toRecipients = [NSArray arrayWithObjects:@"", nil];
[mailer setToRecipients:toRecipients];

NSString *emailBody =[NSString stringWithFormat:@"Product Ordered\n Product Name & Quantity :%@ \n Contact Person :\n %@ \n Mobile Number 1 :\n %@ \n Mobile Number 2 :\n %@ \n Address : %@ \n Email : %@",[globaldict orderedproduct],name.text,mobileno.text,mobileno1.text,address.text,email.text];
[mailer setMessageBody:emailBody isHTML:NO];

[self presentViewController:mailer animated:YES completion:nil];

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failure"
message:@"Your device doesn't support the composer sheet"
otherButtonTitles: nil];
[alert show];


- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
switch (result)
case MFMailComposeResultCancelled:
NSLog(@"Mail cancelled: you cancelled the operation and no email message was queued");
case MFMailComposeResultSaved:
NSLog(@"Mail saved: you saved the email message in the Drafts folder");
case MFMailComposeResultSent:
NSLog(@"Mail send: the email message is queued in the outbox. It is ready to send the next time the user connects to email");
case MFMailComposeResultFailed:
NSLog(@"Mail failed: the email message was nog saved or queued, possibly due to an error");
NSLog(@"Mail not sent");

[self dismissViewControllerAnimated:YES completion:nil];


what is the problem...
Michael Haephrati 1-Jul-13 12:14pm    
Please indent your source code... What error are you receiving?
SanjeevJayaram 2-Jul-13 3:10am    
Actually i tried to send mail through simulator so i didn't get mail. i tried in device and now it works.
I indent the code next time and thanks for your advice :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900