简体   繁体   中英

How to Send the Output of a Dialog Box to an email adress in applescript

I would like to be able to send the output of a dialog box to my email. What would be the best way to do such a thing?

It would be something sort of like this:

repeat
   display dialog "Enter some text:" buttons {"Git Goin"} default answer ""
   set theNewInfo to text returned of result
   if theNewInfo ≠ "" then exit repeat
end repeat

Its a really simple script for a proof of concept, but what I want is as follows: When they enter any text into the dialog box, for that text to be sent to my email, regardless of what it contains.The Subject would say "NewInfo" and the body would contain the text entered into the dialog box

You should post what code you have... too many questions still to be able to answer you reliably. What are you wanting to send to the email message? email addy? subject? body? etc. Basically, you capture the result of the dialog and then put it into a "mailto:" URL string and then use 'open location' on the URL. This should be enough to get you started:

set dialogResult to display dialog "Enter the subject" default answer "My subject" buttons {"me@example.com", "you@example.com"} default button 1

set theAddress to button returned of dialogResult
set theSubject to text returned of dialogResult
set theBody to "This%20is%20the%20body%20text:%0AMore%20text"

-- Must encode entities, spaces as %20 and line breaks as %0A (%0D%0A), etc.
set theSubject to findReplace(" ", "%20", theSubject)
set theSubject to findReplace(return, "%0A", theSubject)

set theURL to "mailto:" & theAddress & "?subject=" & theSubject & "&body=" & theBody

open location theURL

on findReplace(f, r, s)
    set otid to AppleScript's text item delimiters
    set AppleScript's text item delimiters to f
    set s to text items of s
    set AppleScript's text item delimiters to r
    set s to s as string
    set AppleScript's text item delimiters to otid
    return s
end findReplace

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM