Applescript邮件附件未发送

Applescript邮件附件未发送,applescript,email-attachments,Applescript,Email Attachments,以下Applescript成功发送电子邮件,但未附加wav文件。你能告诉我我做错了什么吗?多谢各位 tell application "Mail" set theSubject to "Voicemail" set theContent to read (the POSIX path of "/private/tmp/voice.tgCrnv/BODY.txt") set theAddress to "me@example1.com" set theSe

以下Applescript成功发送电子邮件,但未附加wav文件。你能告诉我我做错了什么吗?多谢各位

    tell application "Mail"

    set theSubject to "Voicemail"
    set theContent to read (the POSIX path of "/private/tmp/voice.tgCrnv/BODY.txt")
    set theAddress to "me@example1.com"
    set theSender to "me@example2.com"
    set theAttachmentFile to (POSIX file "/private/tmp/voice.tgCrnv/msg_1bb3b4f2-c6b1-4012-89c0-a19177cc6ca2.wav") as string

    set msg to make new outgoing message with properties {subject:theSubject, content:theContent, visible:false, sender:theSender}

    tell msg to make new to recipient at end of every to recipient with properties {address:theAddress}
    tell msg to make new attachment with properties {file name:theAttachmentFile as alias}

    send msg
end tell

我已经稍微调整了您的脚本,我相信如果您在进行任何编辑以适应您自己的编码风格(显然,请填写适当的电子邮件地址)之前先尝试一下,它会起作用

重要的功能变化是,在声明新的
传出消息时,将
可见
设置为
真实
;以及针对
传出消息的
内容
,以附加文件

我用
tell应用程序
块移出变量声明,只是为了更好地进行编码(不需要告诉Mail设置这些变量,所以不要这样做)

最后,为了提高可读性,我将代码文本重新格式化为我更习惯的格式

    set theSubject to "Voicemail"
    set theContent to read "/private/tmp/voice.tgCrnv/BODY.txt"
    set theAddress to "me@example1.com"
    set theSender to "me@example2.com"
    set theAttachmentFile to POSIX file "/private/tmp/voice.tgCrnv/msg_1bb3b4f2-c6b1-4012-89c0-a19177cc6ca2.wav" as alias

    tell application "Mail" to tell (make new outgoing message with properties ¬
        {subject:theSubject, content:theContent, visible:true, sender:theSender})

        make new to recipient at end of to recipients ¬
            with properties {address:theAddress}

        tell its content to make new attachment at after the last paragraph ¬
            with properties {file name:theAttachmentFile}

        send
    end tell
让我知道进展如何。

这是我的工作

set theSubject to "Voicemail"
set theContent to read "/private/tmp/voice.tgCrnv/BODY.txt"
set theAddress to "me@example1.com"
set theSender to "me@example2.com"
set theAttachmentFile to "/private/tmp/voice.tgCrnv/msg_1bb3b4f2-c6b1-4012-89c0-a19177cc6ca2.wav" as POSIX file as alias

tell application "Mail"
    set msg to make new outgoing message with properties ¬
        {subject:theSubject, content:theContent, visible:false, sender:theSender}
    tell msg
        make new to recipient at end of every to recipient with properties {address:theAddress}
        make new attachment at end of last character of content with properties ¬
            {file name:theAttachmentFile}
    end tell
    delay 1
    send msg
end tell

FWIW:较大的文件需要更长的延迟。10mb-我知道,太大了,但是…-需要8秒以上的延迟。

当您第一次声明时,请尝试在您的
传出消息的属性中声明
visible:true
,即
set msg以创建具有属性的新传出消息{subject:theSubject,content:theContent,visible:true,sender:theSender}
。。它成功了。然后我尝试了一个60MB的wave文件,但没有成功。我猜文件太大,无法通过电子邮件发送。您可能需要先将wave文件转换为MP3格式(小得多),然后再发送MP3instead@CJK-谢谢,但那没用现在我也不行了。。它与0 kB的wave文件一起工作。。大家抓紧点,我会想出解决办法的,谢谢。我在脚本编辑器中尝试了您编辑的脚本。同样,它正确地发送了电子邮件,只是没有附件。脚本编辑器在事件窗格中显示所有正确的内容。啊。。。我想我的系统在访问和附加文件方面比你的系统稍微快一点。我的
jpg
只有几百KB,所以我确信它足以满足您的需要。哦,我很高兴你解决了这个问题。我看到我们向邮件发送命令和设置附件的方式有轻微的语法差异,但我不明白为什么一个有效,另一个无效。通过编程,您和我创建了相同的脚本,除了
delay
。无论如何,干得好。你应该得到+1的分数。@CJK实际上,我本来会对脚本的措辞稍有不同,但我想把你打倒。LOLWell down,延迟很重要。在莫哈韦,发送附件,至少对我来说,是断断续续和不可靠的,即使延迟很长时间。但是,纯属偶然,我发现如果邮件应用程序被激活,一切都能正常工作。只需在“告诉…”之后立即添加一个激活命令