Applescript:通过Skype将邮件主题转发为手机短信(SMS)

Applescript:通过Skype将邮件主题转发为手机短信(SMS),applescript,Applescript,在apple mail(mail.app)中,我定义了一个规则,在接收电子邮件时调用applescript。脚本应通过Skype以短信形式发送邮件主题(还应发送发件人姓名)。我已经有了一个脚本,可以发送一些硬编码文本作为SMS,但我不知道如何将邮件中的主题和发件人名称传递到该SMS中。这是我的剧本: # Code adapted from: # http://photolifetoys.blogspot.de/2011/12/applescript-control-over-skype-call

在apple mail(mail.app)中,我定义了一个规则,在接收电子邮件时调用applescript。脚本应通过Skype以短信形式发送邮件主题(还应发送发件人姓名)。我已经有了一个脚本,可以发送一些硬编码文本作为SMS,但我不知道如何将邮件中的主题和发件人名称传递到该SMS中。这是我的剧本:

# Code adapted from:
# http://photolifetoys.blogspot.de/2011/12/applescript-control-over-skype-call.html

# VARIABLES
set callToAnumber to "+01234567890"
set SMSmessageBody to " has sent a mail."
set SenderOfMail to "TheSenderOfTheEmail"
set MailSubject to "TheSubjectOfTheMail" 


# BODY
set smstext to "SenderOfMail" & SMSmessageBody as Unicode text
tell application "Skype"
    set message to send command "CREATE SMS OUTGOING " & callToAnumber script name "SMS"
    set smsid to item 2 of every word of message
    send command "SET SMS " & smsid & " BODY " & smstext script name "SMS"
    set result to send command "ALTER SMS " & smsid & " SEND" script name "SMS"
    #display dialog "SMS send! Text: " & smstext
end tell

现在我知道答案了。代码如下:

using terms from application "Mail"
    on perform mail action with messages these_messages for rule this_rule
        tell application "Mail"
            set the message_count to the count of these_messages
            repeat with i from 1 to the message_count
                set this_message to item i of these_messages

                -- GET THE SENDER OF THIS MESSAGE
                set this_sender to the sender of this_message
                -- GET SUBJECT OF MESSAGE
                try
                    set this_subject to (subject of this_message) as Unicode text
                    if this_subject is "" then error
                on error
                    set this_subject to "NO SUBJECT"
                end try
                -- GET CONTENT OF MESSAGE
                try
                    set this_content to (every character of content of this_message) as Unicode text
                    if this_content is in {"", "?"} then error
                on error error_message
                    set this_content to "NO CONTENT"
                end try
            end repeat
        end tell
        set callToAnumber to "+0123456789"

        # BODY
        set smstext to this_subject as Unicode text
        tell application "Skype"
            set message to send command "CREATE SMS OUTGOING " & callToAnumber script name "SMS"
            set smsid to item 2 of every word of message
            send command "SET SMS " & smsid & " BODY " & smstext script name "SMS"
            set result to send command "ALTER SMS " & smsid & " SEND" script name "SMS"
            #display dialog "SMS send! Text: " & smstext
        end tell
    end perform mail action with messages
end using terms from

您正在使用哪个邮件客户端?苹果的Mail.app还是别的什么?我正在使用Mail.app。毫无疑问,很难理解你在这个问题上想要什么。您是否正在寻找如何从邮件应用程序中检索发件人和主题并将其存储为变量?您是否在寻找为您编写的代码,以执行您所解释的应该发生的事情?到目前为止,你已经从一个5-6年的脚本中抓取了两个块,并说它不能做你想做的,你不知道如何让它做额外的事情。让一个5-6年的脚本根据你的特定需要重写可能会很困难。对您希望得到的帮助进行一点澄清可能会有所帮助。抱歉,我不清楚:我不知道如何抓住主题,然后将其传递到代码的SMS部分……但现在我发现这很容易做到,并回答了我自己的问题。