您可以使用Gmail連接發送郵件,您可以將郵件發送給用戶,因爲您需要在代碼中插入一些代碼和設置,以用於發送郵件的代碼。
- (IBAction)sendMessageInBack:(id)anObject{
NSLog(@"Start Sending");
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"sample.pdf"];
NSData *dataObj = [NSData dataWithContentsOfFile:writableDBPath];
SKPSMTPMessage *testMsg = [[SKPSMTPMessage alloc] init];
testMsg.fromEmail = @"Your mail id";
testMsg.toEmail = @"sender mail ids";
testMsg.relayHost = @"smtp.gmail.com";
testMsg.requiresAuth = YES;
testMsg.login = @"Uour mail id";
testMsg.pass = @"your pass";
testMsg.subject = @"Test application ";
testMsg.wantsSecure = YES; // smtp.gmail.com doesn't work without TLS!
// Only do this for self-signed certs!
// testMsg.validateSSLChain = NO;
testMsg.delegate = self;
NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:@"text/plain",kSKPSMTPPartContentTypeKey,
@"Some text to include in body",kSKPSMTPPartMessageKey,@"8bit",kSKPSMTPPartContentTransferEncodingKey,nil];
testMsg.parts = [NSArray arrayWithObjects:plainPart,nil];
[testMsg send];
}
-(void)messageSent:(SKPSMTPMessage *)message{
[message release];
NSLog(@"delegate - message sent");
}
-(void)messageFailed:(SKPSMTPMessage *)message error:(NSError *)error{
[message release];
// open an alert with just an OK button
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Unable to send email" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
[alert release];
NSLog(@"delegate - error(%d): %@", [error code], [error localizedDescription]);
}
並將以下文件複製到您的項目中。

要下載的樣本code here.
我面臨着同樣的problem..but時,我想我的設備上它工作得很好..感謝lukya的說明。 – 2011-10-13 10:46:00
對於我的任務,我只需要顯示作曲家。但我無法這樣做。 MFMailComposeViewController * composeVC = [[MFMailComposeViewController alloc] init]; 。這條線彈出警報控制器 – 2017-12-15 07:45:45