0
votes

I have two questions with my applescript. The script is supposed to send a dropped file as attachment by email and asking the object of the mail from a list. The content of the message MUST be empty.

1) How to set an "empty" email signature because the content of my mail should be empty. I receive an error code "error in mail impossible to solve signature..."

2) I wish that the user can modify the value list {"00111111111111-number1, "0011111111111-number2"...} and add more numbers. What is the best approach to do this ?

Thanks very much in advance for your suggestions.

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
2

2 Answers

0
votes

I also experienced some issues with the signature and the attachement together. if you remove the line "make new attachment..." the signature line is working. Also if you move the signature line before the attachement line, and make a break before the attachement, the signature will be OK. bug ?

Then, based on my tests, if you do not want signature at all, just delete the line "set message signature..." by default, no signature will be set. My last comment is to reduce your script by adding the content directly in property list of the "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

I tried it, and it is creates mail with no content and no signature as expected (Mail 8.2)

0
votes

to add new item in the list, may be this could help you ?

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