「メールで共有」などを行うにはどうすればよいですか? NSSharingServices
メールを選択するときのように。たとえば、私はimage2NSImage
のような結果を達成したいと考えています。どうすればいいですか?ポインタはありますか?
画像1:
画像2:
テキストのみからメッセージを作成するには、次のことができます。
NSURL * url;
url = [NSURL URLWithString:@"mailto:"
"?subject="
"&body=text"
];
(void) [[NSWorkspace sharedWorkspace] openURL:url];
しかし、画像付きのメッセージを作成するにはどうすればよいかわかりません。
ScriptingBridge フレームワークを使用するときに添付ファイルを追加する方法を見つけました。コード:
MailApplication *mail = [SBApplication
applicationWithBundleIdentifier:@"com.apple.Mail"];
MailOutgoingMessage *emailMessage =
[[[mail classForScriptingClass:@"outgoing message"] alloc]
initWithProperties:
[NSDictionary dictionaryWithObjectsAndKeys:
@"this is my subject", @"subject",
@"this is my content", @"content",
nil]];
[[mail outgoingMessages] addObject: emailMessage];
emailMessage.visible = YES;
NSString *attachmentFilePath = [NSString stringWithUTF8String:"<my provided file path>"];
if ( [attachmentFilePath length] > 0 ) {
MailAttachment *theAttachment = [[[mail
classForScriptingClass:@"attachment"] alloc]
initWithProperties:
[NSDictionary dictionaryWithObjectsAndKeys:
attachmentFilePath, @"fileName",
nil]];
[[emailMessage.content attachments] addObject: theAttachment];
}
[emailMessage visible];
できます。しかし、添付ファイルに NSImage を追加する方法は? Maby NSImage を一時ファイルに書き込んでから、添付ファイルとして追加して一時ファイルを削除する必要がありますか? または何?それとも、どうにかして NSImage を本体に追加する必要がありますか?