如何在可可Mac OSX应用程序中使用NSWorkSpace添加默认邮件应用程序的附件 [英] How can we add attachment to default mail Application Using NSWorkSpace in cocoa Mac OSX application

查看:201
本文介绍了如何在可可Mac OSX应用程序中使用NSWorkSpace添加默认邮件应用程序的附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用NSWorkspace通过我的应用程序在默认邮件应用程序中设置TO,CC,BCC,SUBJECT和正文。如何使用NSWrokSpace添加附件?
有没有办法使用NSWorkSpace在默认邮件应用程序中附加文件?
我已尝试使用NSSharingService,但NSSharingService的问题是您不能在默认应用程序电子邮件撰写中设置CC和BCC电子邮件地址。
有没有办法添加CC,而BCC收件人使用NSSharingSerivce?
还是有什么办法使用NSWorkSpace在邮件中添加附件?
我的代码打开和设置TO,CC和BCC在这里

I am using NSWorkspace to set TO, CC, BCC , SUBJECT and body text in default mail application through my application. How can i add attachments using NSWrokSpace? Is there any way to attach files in the default mail app using 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. Is there any way to add CC, and BCC recipients using NSSharingSerivce ?? or is there any way to add attachments in mail using NSWorkSpace?? My code to open and set TO, CC and BCC is here

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

并使用NSSharingService我可以设置只有收件人为TO

And Using NSSharingService i can set only recipients as TO

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

谢谢!

推荐答案

它看起来像 NSSharingService 具有方法 performWithItems ,它采用你想分享的东西

It looks like NSSharingService has the method performWithItems, which takes an array of the things you want to share.

看来,您可以创建一个类型为 NSSharingServiceNameComposeEmail 的共享服务,然后附加消息正文和文件以附加

It appears you can create a sharing service of type NSSharingServiceNameComposeEmail and then attach a message body and a file to attach.

之前我从未使用过 NSSharingService ,所以上面是基于一些谷歌搜索和阅读文档。 (而且我这几天大部分都在iOS上工作,所以我的Mac OS有点过时。)

I've never used NSSharingService before, so the above is based on some Googling and reading the docs. (And I mostly work in iOS these days so my Mac OS is getting a little stale.)

查看此链接:

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

这篇关于如何在可可Mac OSX应用程序中使用NSWorkSpace添加默认邮件应用程序的附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆