2015-10-07 19 views
0

我有两个问题与我的applescript。该脚本应该通过电子邮件发送一个删除的文件作为附件,并从列表中询问邮件的对象。 消息的内容必须为空。Applescript和空邮件签名/输入值列表

1)如何设置“空”电子邮件签名,因为我的邮件内容应该是空的。我收到一个错误代码“邮件中的错误不可能解决签名...”

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 

回答

0

要在列表中添加新项目,可能是这可以帮助你吗?

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 
+0

谢谢。但是下次可以保存新项目吗? – wondernewbie

+0

我只是在上面的脚本中添加行来添加在BaseList中输入的新项目(第11行,结束重复之前) – pbell

0

我也经历了签名和attachement在一起的一些问题。如果删除行“make new attachment ...”签名行正在工作,如果您在签名行前面移动签名行,并在公文前休息一下这个签名就可以了。错误?

然后,根据我的测试,如果你根本不需要签名,只需要删除“set message signature ...”这一行默认情况下,不会设置签名。 我最后的意见是通过增加直接在的属性列表中的内容,以减少脚本“作出新的传出消息......”

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 

我试了一下,它是没有内容,没有签名创建邮件如预期的那样(邮件8.2)

+0

感谢您的回答,即使签名设置为电子邮件帐户,但如果您删除了“签名”行,它也能正常工作。在我的先例测试中,我可能犯了一个错误,因为它没有工作,并且签名被添加,即使没有“签名”行。无论如何非常感谢! 你对我的第二个问题有想法吗?我怎样才能让用户在列表中添加一些数字? 谢谢。 – wondernewbie

+0

将数字添加到列表中:您正在触摸Applescript用户界面的限制。我建议你在列表中添加一个值“添加新项目”。那么用户将能够点击确定或取消,如果他选择了“添加新项目”,那么您将显示一个新对话框询问新条目。 – pbell