2013-01-03 1 views
-2

내 iPhone 응용 프로그램에서 MFMailComposer에 첨부 파일을 추가하고 있습니다. 링크 URL 링크로 그 첨부 파일은 PDF 파일입니다. 보내기를 클릭하면 URL 링크가 대상 메일 주소로 전송되지 않습니다.URL 링크가 이메일에서 전송되지 않습니다.

내가 첨부 할 아마 여부 나는 당신의 질문을 이해 확실하지 오전

-(void)sendMail 
{ 
    MFMailComposeViewController *mailView= [[MFMailComposeViewController alloc] init]; 
    mailView.mailComposeDelegate=self; 
    [mailView setSubject:titleString]; 
    NSArray *array = [[NSArray alloc]initWithObjects:emailString, nil]; 
    [mailView setToRecipients:array]; 
    NSData *textData = [NSData dataWithContentsOfFile:self.fileString]; 
    [mailView addAttachmentData:textData mimeType:@"text/plain" fileName:self.fileString]; 

    [mailView setMessageBody:self.templatetextstring isHTML:YES]; 
    [self presentModalViewController:mailView animated:YES]; 
} 
+1

시도한 코드를 붙여 넣으십시오 –

+0

링크를 추가하는 경우 전자 메일 본문에 넣지 않으시겠습니까? – propstm

+0

가능한 복제본 [MFMailComposeViewController : 클릭 가능한 URL 링크를 전자 메일 메시지 본문에 포함시키는 방법] (http://stackoverflow.com/questions/2058447/mfmailcomposeviewcontroller-how-do-i-embed-a-clickable-url- 이메일에 링크) – petert

답변

2

사용

NSString *link = [NSString stringWithFormat:@"http://www.google.com"]; 
[controller setMessageBody:[NSString stringWithFormat:@"<p><font size=\"2\" face=\"Helvetica\"><a href=%@></br>%@</br></a></br></font></p>",link,@"Google"] isHTML:YES]; 

는 당신을 희망이 도움이 코드 ..

1

이 코드를 사용하고 pdf 문서 또는 pdf 문서에 대한 링크를 추가하기 원하는지 여부를 묻는 질문에 답할 것입니다. 여기에 내가 PDF로 확장 (MIME 타입)을 설정 한 다음의 이름을 설정

- (void)emailFile 
{ 
    if(![MFMailComposeViewController canSendMail]) { 
     UIAlertView *cantSend = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Device not configured to send email" delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil]; 
     [cantSend show]; 
    } else { 
     MFMailComposeViewController *mailView = [[MFMailComposeViewController alloc] init]; 
     mailView.mailComposeDelegate = self; 

     [mailView setSubject:@"PDF Attached to email"]; 

     // Adding an actual PDF document to the email. 
     [mailView addAttachmentData:(__bridge NSData *)myPDFData mimeType:@"pdf" fileName:@"AttachedPDFDocument"]; 

     [mailView setMessageBody:[NSString stringWithFormat:@"Sending %@. This email maybe sent as junk mail",fileName] isHTML:NO]; 
     [self presentModalViewController:mailView animated:YES]; 
    } 
} 

공지 사항 난 다음 PDF 데이터가 아닌 실제 PDF를 추가하고 오전 이메일로 PDF 데이터를 연결하는 데 사용하는 코드는 당신이 만들고있는 전자 메일에 첨부 파일을 추가하는 것이 간단합니다.

은 당신이 모든 데이터가 첫 번째 예는 HTML을 사용하지 않는 반면, HTML을 사용하도록 setMessage을 설정하는 넣어 부착되지 않은 단순한
- (void)emailFile 
{ 
    if(![MFMailComposeViewController canSendMail]) { 
     UIAlertView *cantSend = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Device not configured to send email" delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil]; 
     [cantSend show]; 
    } else { 
     MFMailComposeViewController *mailView = [[MFMailComposeViewController alloc] init]; 
     mailView.mailComposeDelegate = self; 

     [mailView setSubject:@"PDF Link added in HTML"]; 

     // Adding a HTML Link to an email. Remembering to set the Message to allow HTML. 
     NSString *link = [NSString stringWithFormat:@"http://www.google.com"]; 
     [mailView setMessageBody:[NSString stringWithFormat:@"<p><font size=\"2\" face=\"Helvetica\"><a href=%@></br>%@</br></a></br></font></p>",link,@"Google"] isHTML:YES]; 

     [self presentModalViewController:mailView animated:YES]; 
    } 
} 

등의 공지 사항입니다 이메일에 대한 링크를 추가하려면 . 이제 html 요소가 포함 된 메시지 본문에 NSString을 설정할 수 있습니다.

편집

myPDFData 내가 웹 서비스에서 다운로드 한 후 사용자가 이메일을 통해 자신에게 전달 할 수있는 PDF의 dataContent의 CFDataRef입니다. ARC을 사용하는 경우 attachmentData를 설정할 때 (__bridge NSData *)myPDFData에 브릿지를 추가해야합니다.

희망이 도움이됩니다.