0

メールを介してフェッチして目的の結果を取得するapplescriptを探しています。

メールの件名: Registrierung fuer die Badener Hochzeitstage - 2587 (番号が必要です)

必要なメールの内容は、「Frau/Herr/Firma」から次の「space」までの名前です。

php/mysql コードにエラーがあり、データベースにこれがないため、約 400 通の電子メールを解析する必要があります。

tell application "Mail"

set theMessages to message 1 of mailbox "INBOX" of account "Die Badenerhochzeitstage" whose subject begins with "Registrierung fuer"
set theContent to content of theMessages

set someData to paragraphs of theContent
repeat with someData in theContent

    if someData begins with "Firma" then
        set theURL to paragraph of someData
    else
        set theURL to paragraph 10 of theContent -- this works but this line can change weekly
    end if
end repeat

end tell

ここで試してみましたが、結果として、私が望んでいたものではなく、いくつかの行が得られました。

4

2 に答える 2

0

これを試して:

   set TID to text item delimiters
set myRecords to {}

set outputFile to quoted form of (POSIX path of ((path to desktop as text) & "LaunchAgent_Alert.txt")) -- represents "MacHD:Users:david:Desktop:result.txt"

tell application "Mail" to set theMessages to every message of mailbox "INBOX" of account "Badener Hochzeitstage" whose subject begins with "Registrierung fuer"

repeat with aMessage in theMessages
   tell application "Mail" to set {mSubject, mContent} to {subject, content} of aMessage
   set AppleScript's text item delimiters to "-"
   set mSubject to text item 2 of mSubject

   set AppleScript's text item delimiters to "Herr/Frau/Firma "
   set mContent to first word of (text item 2 of mContent)

   set end of myRecords to {mSubject & return & mContent & return & return}

end repeat

set myRecords to myRecords as text
do shell script "echo " & myRecords & " > " & outputFile

set text item delimiters to TID
于 2012-10-10T20:03:35.497 に答える
0

これを試して...

set theAccount to "Die Badenerhochzeitstage"
set subjectText to "Registrierung fuer"
set subjectSearch to "-"
set contentSearch to "Frau/Herr/Firma"
set theResults to {}

tell application "Mail"
    try
        set theMessages to messages of mailbox "INBOX" of account theAccount whose subject begins with subjectText
        if theMessages is {} then
            display dialog "No Messages were found which begins with:" & return & subjectText buttons {"OK"} default button 1
            return
        end if

        repeat with aMessage in theMessages
            tell aMessage
                set theSubject to subject
                set theContent to content
            end tell
            set theNumber to my getFirstWordAfterSearchText(subjectSearch, theSubject)
            set theWord to my getFirstWordAfterSearchText(contentSearch, theContent)
            set end of theResults to {theNumber, theWord}
        end repeat
    on error theError
        display dialog theError buttons {"OK"} default button 1
        return
    end try
end tell
return theResults

(*============== SUBROUTINES =================*)
on getFirstWordAfterSearchText(searchString, theText)
    try
        set {tids, AppleScript's text item delimiters} to {AppleScript's text item delimiters, searchString}
        set textItems to text items of theText
        set AppleScript's text item delimiters to tids
        return (first word of (item 2 of textItems))
    on error theError
        return ""
    end try
end getFirstWordAfterSearchText
于 2012-10-11T01:25:26.433 に答える