[英]Accepting “Share as attachment” functionality as a Mac email client
我正在嘗試制作一個超簡單的“電子郵件客戶端”,以接受將文件/文檔作為電子郵件附件發送的應用內功能。 目前,我不需要任何其他電子郵件功能(我會將數據傳遞到gmail api調用上以在網絡郵件上草擬一條消息),我所需要的只是使該應用程序被視為有效的電子郵件應用程序並接受系統調用以發送電子郵件附件。
到目前為止,我發現我可以將Mail.app首選項配置為使用其他電子郵件應用程序,只要它已被編譯即可(從Xcode而不是AppleScript應用程序),但是我無法將任何測試應用程序與其他應用程序的共享/發送功能配合使用。 除非配置為使用Mail或Outlook作為我的菜單項,否則該菜單項將變灰或拋出錯誤(“ SendMail不知道如何與您的默認郵件客戶端通信。請選擇其他郵件應用程序。”)電子郵件客戶端,在這種情況下可以正常工作。
接受這些系統調用以發送電子郵件將需要什么? 我只需要獲取發送的數據,然后從那里進行處理即可。
您的客戶端應用程序必須自行注冊以使用mailto
URL方案。 將此添加到您的Info.plist:
<array>
<dict>
<key>CFBundleURLName</key>
<string>mailto: urls</string>
<key>CFBundleURLSchemes</key>
<array>
<string>mailto</string>
</array>
</dict>
</array>
</plist>
它需要處理事件。 這可以是一個開始:
- (void)applicationWillFinishLaunching:(NSNotification *)aNotification
{
NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager];
[appleEventManager setEventHandler:self
andSelector:@selector(handleGetURLEvent:withReplyEvent:)
forEventClass:kInternetEventClass
andEventID:kAEGetURL];
}
- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
{
NSString *link = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
/* do something with the link */
}
[對我來說]不清楚您將如何發送附件。 共享>在Finder中發送電子郵件? 無論如何,您可能需要添加一些內容來處理附件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.