简体   繁体   English

我们如何在cocoa Mac OSX应用程序中使用NSWorkSpace添加附件到默认邮件应用程序

[英]How can we add attachment to default mail Application Using NSWorkSpace in cocoa Mac OSX application

I am using NSWorkspace to set TO, CC, BCC , SUBJECT and body text in default mail application through my application. 我正在使用NSWorkspace通过我的应用程序在默认邮件应用程序中设置TO,CC,BCC,SUBJECT和正文。 How can i add attachments using NSWrokSpace? 如何使用NSWrokSpace添加附件? Is there any way to attach files in the default mail app using NSWorkSpace? 有没有办法使用NSWorkSpace在默认邮件应用程序中附加文件? I have tried using NSSharingService but problem with NSSharingService is that you cannot set CC and BCC email addresses in the default application Email Compose. 我尝试过使用NSSharingService,但NSSharingService的问题是您无法在默认应用程序Email Compose中设置CC和BCC电子邮件地址。 Is there any way to add CC, and BCC recipients using NSSharingSerivce ?? 有没有办法添加CC和BCC收件人使用NSSharingSerivce? or is there any way to add attachments in mail using NSWorkSpace?? 或者有没有办法使用NSWorkSpace在邮件中添加附件? My code to open and set TO, CC and BCC is here 我打开并设置TO,CC和BCC的代码就在这里

 NSWorkspace.sharedWorkspace().openURL(NSURL.init(string:"mai‌​lto:(self.txtTo.‌​stringValue)"+"?subj‌​ect=YourSubject"+"&c‌​c="+self.txtCC.strin‌​gValue+"&bcc="+self.‌​txtBcc.stringValue)!‌​)

And Using NSSharingService i can set only recipients as TO 并且使用NSSharingService我只能将收件人设置为TO

 service!.recipients = [self.txtTo.stringValue]
 service!.subject = "Subject"

thanks!. 谢谢!。

It looks like NSSharingService has the method performWithItems , which takes an array of the things you want to share. 看起来NSSharingService有方法performWithItems ,它接受你想要共享的东西的数组。

It appears you can create a sharing service of type NSSharingServiceNameComposeEmail and then attach a message body and a file to attach. 您似乎可以创建NSSharingServiceNameComposeEmail类型的共享服务,然后附加消息正文和要附加的文件。

I've never used NSSharingService before, so the above is based on some Googling and reading the docs. 我之前从未使用过NSSharingService ,所以上面的内容是基于一些谷歌搜索和阅读文档。 (And I mostly work in iOS these days so my Mac OS is getting a little stale.) (而且我现在大多数都在iOS上工作,所以我的Mac OS变得有点陈旧。)

Check out this link: 看看这个链接:

http://cutecoder.org/featured/programmatically-sending-rich-text-mail-attachment-mac/ http://cutecoder.org/featured/programmatically-sending-rich-text-mail-attachment-mac/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM