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 좋은 .. 감사했다. –
내 작업을 위해서 나는 단지 작곡가를 보여줄 필요가있다. 그러나 나는 그렇게 할 수 없다. MFMailComposeViewController * composeVC = [[MFMailComposeViewController alloc] init]; . 이 줄은 경고 컨트롤러를 팝업합니다. –