Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
521 views
in Technique[技术] by (71.8m points)

cocoa touch - iPhone send email not using MessageUI

HI, I am looking for help, I am new to cocoa and iphone programming

Is there a way to send an email, using standard account configured on the device WITHOUT opening a compose UI?

I want to write an app to send me email reminders.

you have a text area where you type something, when you hit button send at the titlebar it sends contents of text area to my email, that's it

I have done the text area and button thing, but it opens me a compose window, when I use MFMailComposeViewController...

or maybe using compose window, but hide certain fields, such as to, cc, bcc...

all of articles I've found on the internet are either outdated or about MFMailComposeViewController...

looking forward to hearing a replay from you

Thanks...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It is possible to use MFMailComposeViewController without user interaction. This technique obviously relies on undocumented APIs, so it may break anytime. Also, it wouldn't be a good idea to submit an app doing this to the App Store…

- (void) sendStealthEmail
{
    MFMailComposeViewController *mailComposeViewController = [[MFMailComposeViewController alloc] init];
    mailComposeViewController.mailComposeDelegate = self;
    [mailComposeViewController setToRecipients:[NSArray arrayWithObject:@"[email protected]"]];
    [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];
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...