Applescript邮件附件未发送

时间:2018-06-17 16:11:02

标签: 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 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

3 个答案:

答案 0 :(得分:1)

这项工作对我来说

---
title: "Herding"  
author:   
  - Loana  
institute:   
  - Supervised by   
  - University  
date: Academic year 2017-2018  
output:   
  beamer_presentation:  
    incremental: false  
    theme: "Frankfurt"  
    colortheme: "beaver"  
    fonttheme: "structuresmallcapsserif"  
    toc: true   
    slide_level: 2  
    fig_width: 5  
    fig_height: 4  
    fig_caption: true  
    highlight: tango  
link-citations: yes  
urlcolor: red  
linkcolor: red  
citecolor: blue  
---

----

# Title1

## Subtitle1

Text

----

# Title2

## Subtitle2

- Text
- Text

----

答案 1 :(得分:0)

我稍微调整了您的脚本,我相信如果您在对自己进行编辑之前首先尝试它以适应您自己的编码风格(显然,请填写相应的电子邮件地址)。 / p>

重要的功能变化是在声明新的visible时将true设置为outgoing message;并定位content的{​​{1}}以附加文件。

我为了良好的编码习惯而转移到outgoing message块的变量声明(没有必要告诉 Mail 设置这些变量,所以不要...吨)。

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

tell application

让我知道它是怎么回事。

答案 2 :(得分:0)

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