简体   繁体   English

如何使用小程序告诉邮件保留已发送邮件的副本

[英]How to use applescript to tell Mail to keep a copy of sent message

I use AppleScript and can send messages without any problem, but the "Sent" box does not get a copy of what I sent. 我使用AppleScript,可以毫无问题地发送消息,但是“已发送”框没有得到我发送的副本。 However, if I use Mail Application to send messages, the "Sent" box gets a copy of what I sent. 但是,如果我使用邮件应用程序发送邮件,则“已发送”框将获取我发送的邮件的副本。 So I guess my AppleScript may miss a command or so to tell Mail to keep a copy of the sent messages. 因此,我想我的AppleScript可能会错过一个命令来告诉Mail保留已发送消息的副本。 What's the command that I missed? 我错过了什么命令? Thanks. 谢谢。

tell application "Mail"                                                         
    set theNewMessage to make new outgoing message with properties {subject:theSubject, content:theBody & return & return, visible:true}                       
    tell theNewMessage                                                          
        set visibile to false                                                   
        set sender to theSender                                                 
        make new to recipient at end of to recipients with properties {address:theAddress}                                                                     
        make new attachment with properties {file name:theAttachment} at after the last paragraph                                                              
        send                                                                    
        delay 5                                                                 
    end tell                                                                    
end tell   

I don't think you're missing any command. 我认为您不会丢失任何命令。 I copied your script to Script Editor on my iMac, set values for theSubject, theBody, theAddress, theSender, and theAttachment, and ran it. 我将您的脚本复制到iMac上的“脚本编辑器”中,为“主题”,“正文”,“地址”,“发件人”和“附件”设置值,然后运行它。 It (a) successfully sent the message, and (b) I was able to view the message it sent in my Sent mailbox. 它(a)成功发送了邮件,并且(b)我能够查看它在“已发送”邮箱中发送的消息。

I tried this both with a known sender and with a random example.com sender. 我同时尝试了一个已知的发件人和一个随机的example.com发件人。 In both cases, it was saved in the default Sent box. 在两种情况下,它都保存在默认的“已发送”框中。

So the issue most likely lies elsewhere. 因此,问题很可能在其他地方。 Make sure that the value you're currently using for theSender maps to an account in Mail that saves sent messages. 确保您当前用于theSender的值映射到Mail中用于保存已发送邮件的帐户。 (If it's an IMAP account, it may be saving sent messages on the server, and server behavior may be affecting what you see.) (如果是IMAP帐户,则可能会将已发送的消息保存在服务器上,并且服务器的行为可能会影响您看到的内容。)

If that doesn't work, set up some test values for all of the variables in the script except theAddress (using example.com for theSender), and include those (except theAddress) in your question. 如果那不起作用,请为脚本中除TheAddress以外的所有变量(使用theSender使用example.com)设置一些测试值,并在您的问题中包括这些(测试地址除外)。 (If you can use example.com for theAddress, too, do that, but some servers will simply refuse the message immediately, which makes it worthless for testing this particular case.) (如果您也可以对exampleAddress使用example.com,请执行此操作,但是某些服务器将立即拒绝该消息,这对于测试此特定情况毫无价值。)

Note that you have an error that does not change this behavior; 请注意,您有一个不会更改此行为的错误。 you have “visible” misspelled as “visibile”. 您将“可见”拼写为“可见”。 However, I tried it both ways and in both cases the outgoing message does get stored in the appropriate Sent box. 但是,我尝试了两种方式,在两种情况下都将传出邮件存储在适当的“已发送”框中。

Try adding this after you send the message... 发送消息后,尝试添加此内容...

set accountReference to first account whose name = "my account name"
synchronize with accountReference

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

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