简体   繁体   English

AppleScript:在邮件应用程序中从列表中创建 SmartInbox

[英]AppleScript: Create SmartInbox in Mail app from list

just wondering if you can help只是想知道你是否可以帮忙

I have set out to create Smart mailbox in Mail app using applescript The list of emails for smart inbox are in myFile.txt on desktop.我已经开始使用 applescript 在邮件应用程序中创建智能邮箱智能收件箱的电子邮件列表在桌面上的 myFile.txt 中。 Each line has one email每行有一个电子邮件

I want to the smart Inbox with several emails, and want to automate it我想要带有几封电子邮件的智能收件箱,并希望将其自动化

I have tried the following script我已经尝试了以下脚本

tell application "Mail"
    activate
end tell

# GUI Script to initiate Smart Inbox creation

tell application "System Events"
    tell process "Mail"
        tell menu bar 1
            tell menu bar item "Mailbox"
                tell menu "Mailbox"
                    click menu item "New Smart Mailbox…"
                end tell
            end tell
        end tell
        
        delay 1
        # Set name for the Smart Mailbox
        tell application "System Events" to keystroke ("MyAutomaticSmartMailBox" as text)

        keystroke tab

        # Set path to myFile.txt
        set srcFile to ((path to desktop) as text) & "myFile.txt"
        
        # Read lines from file.
        set lns to paragraphs of (read file srcFile as «class utf8»)
        
        # Loop over lines read and copy each to the clipboard.
        repeat with ln in lns
            set the clipboard to ln
            # Paste the clipboard into Smart inBox dialog
            tell application "System Events" to keystroke (the clipboard as text)
            # to create next line to add email
            click button "NSButtonCell"
        end repeat
        
        
    end tell
end tell

Gives me an error给我一个错误

error "System Events got an error: Can’t make file \"MackintoshHD:Users:one:Desktop:myFile.txt\" of process \"Mail\" into type file." number -1700 from file "MackintoshHD:Users:one:Desktop:myFile.txt" of process "Mail" to file

Any help to resolve this error wud be appreciated Also to change in drop down from "Any Recipient" to "From" in the Script Cheers任何解决此错误的帮助,我们都将不胜感激 还要在 Script Cheers 中将下拉列表从“任何收件人”更改为“发件人”

`set theFile to ((path to desktop as text) & "test.txt")

set theData to paragraphs of (read file theFile)` This shud read the file, set it up as List then repeat with aData in the List set rule tell rule "a" to make new rule with condition at end of.....将数据设置为(读取文件文件)的段落`这将读取文件,将其设置为列表,然后在列表中重复使用数据设置规则告诉规则“a”以在结尾处创建条件为...的新规则。

This shud work :)这真是太棒了:)

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

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