이메일에 라벨 텍스트를 첨부하고 싶습니다. UILabel 내부의 텍스트를 이메일 첨부 파일로 보내려면 어떻게해야합니까? 라벨의 텍스트를 이메일 첨부 파일로 보내는 방법은 무엇입니까?
이
나는 코드를 사용하고 있습니다 :-(IBAction)send:(id)sender {
if ([MFMailComposeViewController canSendMail])
{
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 100, 300, 100)];
label.numberOfLines = 0;
label.textAlignment = UITextAlignmentCenter;
label.text = @"text";
[self.view addSubview:label];
[label release];
MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
mailer.mailComposeDelegate = self;
[mailer setSubject:@"Subject"];
NSString *fileName = @"my file.txt";
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:fileName];
NSData *myData = [NSData dataWithContentsOfFile:path];
[mailer addAttachmentData:myData mimeType:@"text/plain" fileName:fileName];
// Fill out the email body text
NSString *emailBody = @"Email Body";
[mailer setMessageBody:emailBody isHTML:NO];
[self presentModalViewController:mailer animated:YES];
[mailer release];
}
else
{
UIAlertView *alertm = [[UIAlertView alloc] initWithTitle:@"Failure"
message:@"Please make sure that your email application is open"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles: nil];
[alertm show];
[alertm release];
}
}
가 어떻게 라벨이 이메일로 첨부에 링크 할 수 있습니까?
도움이 될 것입니다.
? .txt 파일? – Martol1ni
@woz 그가 자기에게 메시지를 보내달라고 요청했습니다. –
@woz 메일보기 컨트롤러를 열었을 때 첨부 파일을 볼 수있는이 코드로 인해 이메일에 아무 것도 없다면, 나는 이유를 모른다. 저를 도와주세요 ? – 4slices