OSX NSSharingService:如何在电子邮件中发送带有自定义文本的链接

时间:2018-12-01 15:15:36

标签: objective-c macos html-email nssharingservice

对于iOS,我可以使用以下代码发送包含自定义文本的电子邮件链接。

  NSString *emailString = [NSString stringWithFormat:@"<a href=https://www.google.com/>test</a>"];        
  MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
            mailController.mailComposeDelegate = self;

[mailController setMessageBody:emailString isHTML:YES];
        [self presentViewController:mailController animated:YES 
 completion:nil];

但是,我无法为Mac复制相同的功能。

 NSString *emailString = [NSString stringWithFormat:@"<a href=https://www.google.com/>test</a>"]; 
 NSArray *shareItems = @[emailString];
 NSSharingService *service = [NSSharingService sharingServiceNamed:NSSharingServiceNameComposeEmail];
 service.delegate = self;
 [service performWithItems:shareItems]; 

我不知道这是否可行。任何建议表示赞赏

0 个答案:

没有答案