liebus

이메일 발송 본문

예전꺼(2014년이전꺼)/iOS

이메일 발송

리베스 2011. 4. 6. 11:17

아이폰 에서 이메일 발송부분을 구현 할려면 

MessageUI.framework 를 추가해야 한다.  

해더파일에 <MessageUI/MessageUI.h>를 import 하고

MFMailComposeViewControllerDelegate Protocol를 사용해야 한다. 


이 프레임워크를 사용하면 아이폰에서 기본으로 제공하는  E-Mail Component를 사용할 수 있다. 


//Send Mail

MFMailComposeViewController *mailController
                    = [[[
MFMailComposeViewController alloc] init] autorelease];


mailController.mailComposeDelegate = self

[mcvc setSubject:@"Title"]; 
[mcvc setMessageBody:@"Content" isHTML:YES]; 


MFMailComposeViewController를 생성해 주고
setSubject:  메소드와   setMessageBody: 메소드 를 통해  제목과 본문 내용을 적어 준다. 

만약 첨부파일을 넣고 싶으면 addAttachmentData:  메로드를 활용하면 된다.  

[mcvc
addAttachmentData:UIImagePNGRepresentation(sendImage)
                       mimeType:@"image/jpeg" fileName:@"SEND.PNG"]; 

sendImage는 UIImage 객체이고  fileName에 실제 보내고자 하는 이미지 이름이 들어 간다. 


여기 까지 구현한 MFMailComposeViewController 객체를 원하는 형식으로 보여 주면 된다. 


메일 발송 취소를 할경우에는   MFMailComposeViewController  Protocol 의 
- (void)mailComposeController:(MFMailComposeViewController *)controller
     didFinishWithResult:(
MFMailComposeResult)result error:(NSError *)error; 

를 활용 해주면 되시겠다. 

적용한 스샷 되시겠다.


 

'예전꺼(2014년이전꺼) > iOS' 카테고리의 다른 글

scheduler  (0) 2011.04.30
Xcode4 SVN 연결 동영상 링크  (0) 2011.04.19
Xcode 4 Keyboard Shortcuts  (0) 2011.04.06
Documents 에서 이미지 읽기  (0) 2011.03.31
UIView 터치이벤트  (0) 2011.03.28
Comments