22 Kasım 2008, CUMARTESİ
Nasıl bir iPhone uygulamasından posta gönderebilir miyim
Benim iPhone uygulamasından bir e-posta göndermek istiyorum. İOS SDK bir e-posta API olmadığını duydum. Benim uygulama çıkar çünkü aşağıdaki kodu kullanmak istemiyorum:
NSString *url = [NSString stringWithString: @"mailto:foo@example.com?cc=bar@example.com&subject=Greetings from Cupertino!&body=Wish you were here!"];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: url]];
Nasıl benim app bir e-posta gönderebilir miyim?
CEVAP
3 EKİM 2009, CUMARTESİ
İOS 3.0 ve daha sonra MessageUİ çerçeve içinde saklanmış olan MFMailComposeViewController
sınıf MFMailComposeViewControllerDelegate
protokol kullanmanız gerekir.
İlk framework ve ithalat ekleyin:
#import <MessageUI/MFMailComposeViewController.h>
Sonra, bir mesaj göndermek için:
MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setSubject:@"My Subject"];
[controller setMessageBody:@"Hello there." isHTML:NO];
if (controller) [self presentModalViewController:controller animated:YES];
[controller release];
Kullanıcı çalışır ve zaman içinde temsilci geri alıyorum:
- (void)mailComposeController:(MFMailComposeViewController*)controller
didFinishWithResult:(MFMailComposeResult)result
error:(NSError*)error;
{
if (result == MFMailComposeResultSent) {
NSLog(@"It's away!");
}
[self dismissModalViewControllerAnimated:YES];
}
Hatırlarsanız aygıtı e-posta göndermek için yapılandırılmış olup olmadığını kontrol etmek için:
if ([MFMailComposeViewController canSendMail]) {
// Show the composer
} else {
// Handle the error
}
Bunu Paylaş:
Nasıl benim Android uygulaması e-posta...
Nasıl Java uygulaması GMail, Yahoo vey...
Nasıl bir iPhone uygulamasından Safari...
Nasıl biri git deposu e-posta ile gönd...
Nasıl bir istek yükü yerine veri biçim...