Applescript 和空邮件签名/在值列表中输入

Applescript and empty mail signature / input in value list

我的 applescript 有两个问题。该脚本应该通过电子邮件将丢弃的文件作为附件发送,并从列表中询问邮件的对象。 消息的内容必须为空。

1) 如何设置"empty" 邮件签名,因为我的邮件内容应该是空的。我收到错误代码 "error in mail impossible to solve signature..."

2) 我希望用户可以修改值列表 {"00111111111111-number1, "0011111111111-number2"...} 并添加更多数字。执行此操作的最佳方法是什么?

非常感谢您的建议。

property theSubject : "subject"
property theNumber : ""
property theContent : ""
property theSignature : "none"
property onRun : ""

on run
    tell application "Finder"
        set sel to (get selection)
    end tell
    set onRun to 1
    new_mail(sel)
end run

on open droppedFiles
    new_mail(droppedFiles)
end open

on new_mail(theFiles)
set chosen to choose from list {"0011111111111-number1", "0011111111111-number2"} with prompt "Thanks to select"
if chosen is false then return "" -- in case of 'Cancel' return empty string
set theNumber to text 1 thru 13 of (item 1 of chosen) -- as chosen returns a list by default it must be flattened

tell application "Mail"
    set newMessage to make new outgoing message with properties {visible:true, subject:theNumber}
    tell newMessage
        make new to recipient with properties {address:faxboxEmail}
        if onRun < 1 then
            make new attachment with properties {file name:theFiles as alias} at after last paragraph
        end if
        set the content to theContent
        set message signature of newMessage to signature theSignature
    end tell
    activate
    if onRun < 1 then
        send
    end if
end tell
end new_mail

我也遇到了签名和附件的一些问题。如果您删除 "make new attachment..." 行,则签名行有效。另外,如果您将签名行移到附件行之前,并在附件之前打断,签名就可以了。错误?

然后,根据我的测试,如果你根本不需要签名,默认删除"set message signature..."行即可,不会设置签名。 我的最后一条评论是通过直接在 "make new outgoing message..."

的 属性 列表中添加内容来减少您的脚本
tell application "Mail"
set newMessage to make new outgoing message with properties {visible:true, subject:TheNumber, content:TheContent}
tell newMessage
    make new to recipient with properties {address:faxboxmail}
    if onRun > 1 then
        make new attachment with properties {file name:theFile as alias} at after last paragraph
    end if
end tell
activate
end tell

我试过了,它创建的邮件没有预期的内容和签名(Mail 8.2)

要在列表中添加新项目,这对您有帮助吗?

set BaseList to {"0011111111111-number1", "0011111111111-number2"}

set CList to BaseList & {"Add new item"}
set chosen to choose from list CList with prompt "Thanks to select"
if chosen is false then return "" -- in case of 'Cancel' return empty string
if "Add new item" is in chosen then
set OKNew to false
repeat until OKNew
    set NewItem to display dialog "Enter new value :" default answer ""
    set OKNew to (button returned of NewItem is "OK") and (text returned of NewItem is not "")
    set theNumber to text returned of NewItem
set BaseList to baseList & {theNumber}  -- to add the new item in the BaseList
end repeat
else
set theNumber to text 1 thru 13 of (item 1 of chosen) -- as chosen returns a list by default it must be flattened
end if