如何通过applescript将选定邮件中的文件复制到outlook中的传出邮件中?

如何通过applescript将选定邮件中的文件复制到outlook中的传出邮件中?,outlook,applescript,Outlook,Applescript,我一直在想如何通过applescript将outlook中的传入邮件的附件复制到新的传出邮件 下面的代码是我到目前为止得到的,但它肯定是错的。Outlook向我抛出错误并声明:“Microsoft Outlook出现错误:无法在类型文件中生成缺少的值。” 我尝试了其他一些方法,但似乎无法获取传入消息附件的file属性 有没有人有过用这种方式在Outlook和Applescript中处理文件的经验?Dylan 似乎只是在消息之间传递附件不起作用,但首先保存附件,然后将文件名传递到新附件的文件属性

我一直在想如何通过applescript将outlook中的传入邮件的附件复制到新的传出邮件

下面的代码是我到目前为止得到的,但它肯定是错的。Outlook向我抛出错误并声明:“Microsoft Outlook出现错误:无法在类型文件中生成缺少的值。

我尝试了其他一些方法,但似乎无法获取传入消息附件的file属性

有没有人有过用这种方式在Outlook和Applescript中处理文件的经验?

Dylan

似乎只是在消息之间传递附件不起作用,但首先保存附件,然后将文件名传递到新附件的
文件
属性

tell application "Microsoft Outlook"
    local mynames, msg1, msg2, saveToFolder, saveAsName
    set msg1 to last item of incoming messages
    set msg2 to make new outgoing message with properties {subject:"Testing this thing"}
    set saveToFolder to POSIX path of (path to desktop)
    repeat with atts in attachments of msg1
        set saveAsName to saveToFolder & (name of atts)
        log saveAsName
        save atts in saveAsName
        tell msg2
            make new attachment with properties {file:saveAsName} -- with properties {file:atts}
        end tell
    end repeat
    open msg2
end tell
注意1:您可能需要添加逻辑以删除从传入邮件中保存的文件(原始附件)


注意2:另一种选择是从传入消息中查找文件的位置,并使用该别名,而不是先保存它们,然后将它们添加到出站消息中“

Frank”-这非常有效,非常感谢!我想我可以从这里找出删除逻辑,或者我可以定期手动清理我的桌面。
tell application "Microsoft Outlook"
    local mynames, msg1, msg2, saveToFolder, saveAsName
    set msg1 to last item of incoming messages
    set msg2 to make new outgoing message with properties {subject:"Testing this thing"}
    set saveToFolder to POSIX path of (path to desktop)
    repeat with atts in attachments of msg1
        set saveAsName to saveToFolder & (name of atts)
        log saveAsName
        save atts in saveAsName
        tell msg2
            make new attachment with properties {file:saveAsName} -- with properties {file:atts}
        end tell
    end repeat
    open msg2
end tell