获取附件以使用AppleScript for Mail

时间:2017-10-30 11:32:44

标签: macos email pdf applescript attachment

我正在使用Mac OSX 10.12.6,并构建了AppleScript来创建电子邮件,然后附加PDF和jpeg文件。当我运行脚本时,我在尝试附加pdf和jpeg文件时出错。

Mail got an error: Can’t make {file name:"MacintoshHD:Users:peteradam:PPAttachments:EmailFolder:Quote_15018_301017.pdf", file size:200339} into type properties of attachment.

对于更改了文件名的jpeg重复出现错误消息。

我也尝试将theSignaturetheAttachment1设为别名,但无济于事。

脚本如下:

set TheRecipient to "name"
set theAddress to "me@me.com"
set theSubject to "Expoprint  "
set theContent to "When in Doubt DON'T"
set theSender to "Me <me@me.com>"

tell application "Finder" to set theSignature to "MacintoshHD:Users:peteradam:PPAttachments:EmailFolder:ExpoPrint Signature.jpg"
set theSignatureSize to 20530
tell application "Finder" to set theAttachment1 to "MacintoshHD:Users:peteradam:PPAttachments:EmailFolder:Quote_15018_301017.pdf"
set theAttachmentSize1 to 200339

tell application "Mail"
    set theMessage to make new outgoing message with properties {subject:theSubject, content:theContent & return & return, visible:true}
    tell theMessage
        set sender to theSender
        make new to recipient at end of every to recipient with properties {name:TheRecipient, address:theAddress}
        try
            make new attachment with properties {file name:theAttachment1, file size:theAttachmentSize1} at after last paragraph
            set message_Attachment to 0
        on error errmess
            log errmess
            display dialog errmess
            set message_Attachment to 1
        end try
        log "message_attachment =" & message_Attachment
        make new attachment with properties {file name:theSignature, file size:theSignatureSize} at after last paragraph
        delay 1
    end tell
end tell

1 个答案:

答案 0 :(得分:0)

我通过删除文件大小属性

解决了这个问题