Cocoa osx NSSharingServicePicker 设置默认电子邮件地址
Cocoa osx NSSharingServicePicker set default email address
在我 Mac 的应用程序中,我使用 NSSharingServicePicker 来邮寄一些物品。我的问题是我想设置要发送的默认电子邮件地址。如何设置此值以在邮件客户端打开时显示它?
我有这个代码:
NSMutableArray *shareItems = [NSMutableArray arrayWithObject:@"MyText"];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *fileName = [NSString stringWithFormat:@"%@/MyFile.pdf", documentsDirectory];
NSURL* tempFileURL = [NSURL fileURLWithPath:fileName];
[shareItems addObject:tempFileURL];
NSSharingServicePicker *sharingPicker = [[NSSharingServicePicker alloc] initWithItems:shareItems];
sharingPicker.delegate = self;
这就是我想要的。我需要在电子邮件中设置默认目标地址。
抱歉我的英语不好。提前致谢。
已解决:
-(id<NSSharingServiceDelegate>)sharingServicePicker:(NSSharingServicePicker *)sharingServicePicker delegateForSharingService:(NSSharingService *)sharingService
{
[sharingService setRecipients:@[@"email@email.com"]];
[sharingService setSubject:@"MySubject"];
return self;
}
NSSharingServiceNameComposeEmail
通常是实现此目的的标准方法:
NSSharingService *service = [NSSharingService sharingServiceNamed:NSSharingServiceNameComposeEmail];
service.delegate = self;
service.recipients = @[@"tim.cook@apple.com"];
service.subject = [ NSString stringWithFormat:@"%@",NSLocalizedString(@"Re: Requested PDF",nil)];
[service performWithItems:shareItems];
虽然此代码可以与 shareItems
一起使用,但您使用 NSSharingServicePicker
做什么并不十分清楚,因此文件将与正文一起附加。
在我 Mac 的应用程序中,我使用 NSSharingServicePicker 来邮寄一些物品。我的问题是我想设置要发送的默认电子邮件地址。如何设置此值以在邮件客户端打开时显示它?
我有这个代码:
NSMutableArray *shareItems = [NSMutableArray arrayWithObject:@"MyText"];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *fileName = [NSString stringWithFormat:@"%@/MyFile.pdf", documentsDirectory];
NSURL* tempFileURL = [NSURL fileURLWithPath:fileName];
[shareItems addObject:tempFileURL];
NSSharingServicePicker *sharingPicker = [[NSSharingServicePicker alloc] initWithItems:shareItems];
sharingPicker.delegate = self;
这就是我想要的。我需要在电子邮件中设置默认目标地址。
抱歉我的英语不好。提前致谢。
已解决:
-(id<NSSharingServiceDelegate>)sharingServicePicker:(NSSharingServicePicker *)sharingServicePicker delegateForSharingService:(NSSharingService *)sharingService
{
[sharingService setRecipients:@[@"email@email.com"]];
[sharingService setSubject:@"MySubject"];
return self;
}
NSSharingServiceNameComposeEmail
通常是实现此目的的标准方法:
NSSharingService *service = [NSSharingService sharingServiceNamed:NSSharingServiceNameComposeEmail];
service.delegate = self;
service.recipients = @[@"tim.cook@apple.com"];
service.subject = [ NSString stringWithFormat:@"%@",NSLocalizedString(@"Re: Requested PDF",nil)];
[service performWithItems:shareItems];
虽然此代码可以与 shareItems
一起使用,但您使用 NSSharingServicePicker
做什么并不十分清楚,因此文件将与正文一起附加。