使用 ScriptingBridge 框架与 Entourage 进行通信

发布于 2024-09-04 02:14:19 字数 1613 浏览 10 评论 0 原文

我的问题的动机是以下文档,它描述了如何使用 ScriptingBridge 集成 mail.app:

http://developer.apple.com/mac/library/samplecode/SBSendEmail/Introduction/Intro.html

我也尝试对 Entourage 应用类似的技术,但无法得到到目前为止的任何结果。我知道使用 AppleScript 可以帮助我解决问题,并且 mactech.com 有大量相关文档。

但我发现这种 ScriptingBridge 技术很优雅,并且想弄清楚为什么它对我的 Entourage 不起作用。

最大的问题似乎是我无法根据 Mail 中的名称创建脚本类,因为 Entourage 的接口与 Mail 的接口不同,正如其标头所示。

有人可以告诉我我缺少什么或提供任何关于为什么这行不通的提示吗?

我还添加了示例代码

`

MicrosoftEntourageApplication * mail = [SBApplication
applicationWithBundleIdentifier:@"com.Microsoft.Entourage"];
MicrosoftEntourageOutgoingEmailMessage * emailMessage = 
[[[mail classForScriptingClass:@"outgoing message"] alloc]
initWithProperties:
[NSDictionary dictionaryWithObjectsAndKeys:
@"my sample subject", @"subject",
@"my sample body", @"content",
nil]];

//then i create a set of recipients and try to use "to recipient" as the string scripting class id, but MicrosoftEntourageRecipient is returned as nil 

MicrosoftEntourageRecipient * theRecipient =
[[[mail classForScriptingClass:@"to recipient"] alloc]
initWithProperties:
[NSDictionary dictionaryWithObjectsAndKeys:
@"[email protected]", @"address",
nil]];

`

我试图让简单的事情发挥作用,我什至没有专注于我现在应该做的任务。

我是一个 Cocoa 初学者(并且愿意学习),请原谅我的语法幼稚,并在回答我的问题之外在示例代码中指出它们。

最好的问候,

萨勃拉曼尼亚

The motivation for my question is the following doc, which describes how mail.app could be integrated using ScriptingBridge:

http://developer.apple.com/mac/library/samplecode/SBSendEmail/Introduction/Intro.html

I tried to apply a similar technique with Entourage as well but could not get any results so far. I understand that using AppleScript would help me solve my problem and mactech.com has extensive documentation for doing so.

But i find this ScriptingBridge technique elegant and want to figure why it is not working for me with Entourage.

The biggest problem seems to be my inability to create Scripting classes based on their names as it happens in Mail because Entourage has a different interface than Mail as their headers indicate.

Could someone please tell me what I am missing or provide any sort of hint on why this wont work?

I am also adding sample code

`

MicrosoftEntourageApplication * mail = [SBApplication
applicationWithBundleIdentifier:@"com.Microsoft.Entourage"];
MicrosoftEntourageOutgoingEmailMessage * emailMessage = 
[[[mail classForScriptingClass:@"outgoing message"] alloc]
initWithProperties:
[NSDictionary dictionaryWithObjectsAndKeys:
@"my sample subject", @"subject",
@"my sample body", @"content",
nil]];

//then i create a set of recipients and try to use "to recipient" as the string scripting class id, but MicrosoftEntourageRecipient is returned as nil 

MicrosoftEntourageRecipient * theRecipient =
[[[mail classForScriptingClass:@"to recipient"] alloc]
initWithProperties:
[NSDictionary dictionaryWithObjectsAndKeys:
@"[email protected]", @"address",
nil]];

`

I am trying to make the simple thing work, I am not even concentrating on the task I am supposed to do now.

I am a Cocoa beginner( and willing to learn ), please excuse an syntactic naivetes and do point them out in the sample code, in addition to answering my question.

Best Regards,

Subramanian

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

天生の放荡 2024-09-11 02:14:19

一些事情:

  1. 如果您遇到困难,请首先弄清楚如何在 AppleScript 中做到这一点。这就是大多数应用程序脚本编写者所使用的(即最能帮助您的人)以及几乎所有文档的编写目的。 (就像您确实需要学习一些 ObjC 才能从 Python、Ruby 等中使用 Cocoa 一样)。

  2. 脚本桥笨重、混乱且容易出现问题应用程序兼容性问题,因此将工作的 AppleScript 代码转换为它可能会很棘手(如果不是不可能的话),具体取决于您的目标应用程序、您正在使用的命令等等。根据记忆,我认为 Entourage 是它出错的应用程序之一,在这种情况下,除非您求助于使用原始 Apple 事件代码,否则您就不走运了。其他选项有 objc-appscript (m'baby),它不太容易出现此类问题,还有 AppleScriptObjC ( 10.6+),它允许您直接从 AppleScript 调用 ObjC 类,反之亦然。

  3. 您是否看过CSMail

  4. Entourage 将在 Office 2010 中消失,取而代之的是 Outlook,因此您可能不想投入大量时间来弄清楚如何为其编写 SB 代码。

A few things:

  1. If you're stuck, first figure out how to do it in AppleScript. That's what most application scripters use (i.e. the folks best able to help you) and what almost all documentation is written for. Realistically, if you want to do much application scripting, you really need to learn some AppleScript (just as you really need to pick up a bit of ObjC to use Cocoa from Python, Ruby, etc).

  2. Scripting Bridge is clunky, obfuscated and prone to application compatibility problems, so translating working AppleScript code to it can be tricky, if not impossible, depending on the application you're targeting, the commands you're using, and so on. From memory, I think Entourage is one of the apps it trips up on, in which case you're out of luck unless you resort to using raw Apple event codes. Other options are objc-appscript (m'baby), which is much less prone to such problems, and AppleScriptObjC (10.6+), which lets you call ObjC classes directly from AppleScript and vice-versa.

  3. Have you looked at CSMail?

  4. Entourage is going away in Office 2010 in favour of Outlook, so you may not want to invest a huge of time figuring out how to write SB code for it anyway.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文