2011-12-14 29 views
1

我的applescript掛起之前,它可以同步,因爲在Apple Mail中的錯誤,如果SMTP服務器不匹配的描述,它會再次要求密碼..因此,用戶必須輸入他們的密碼,並點擊確定或輸入在任何事情發生之前。 我有一個對話框提示出現說:「在鑰匙串中記住密碼是一個好主意」,然後我有另一個提示激活它的頂部,以便他們不能點擊確定,沒有輸入他們的密碼......但似乎不一致和跛腳。我寧願找出提示不會出現的方式,或者如果我可以暫停腳本直到輸入密碼。Applescript:如何在用戶在Apple Mail中輸入密碼之前停止腳本?

--Activate Mail Application 
tell application "Mail" 
activate "Mail" 
display dialog "Welcome to Mailbox setup with Google Mail. Please enter the password for your e-mail when prompted. This should not take any more than a minute." 

delay 0.5 

--Variables 
--Creating account 


set email_address to (short user name of (system info)) & "@EMAIL.com" 
set full_name to (long user name of (system info)) 
set mailboxname to (long user name of (system info)) 
set shortname to (short user name of (system info)) 
set myPass to text returned of ¬ 
    (display dialog "Enter password for " & ¬ 
     quoted form of shortname ¬ 
     with title ¬ 
     "Gmail" with icon stop ¬ 
     default answer ¬ 
     "" buttons {"Continue…"} ¬ 
     default button 1 ¬ 
     giving up after 5 with hidden answer) 


try 
    set newacct to "imap.gmail.com" 
    set newacct to make new imap account with properties {name:mailboxname, user name:email_address, password:myPass, uses ssl:true, server name:"imap.gmail.com", port:993, full name:full_name, email addresses:{email_address}} 
    tell application "System Events" to key code 53 

    --Create SMTP filter 
    set addsmtp to "smtp.gmail.com" 
    set addsmtp to make new smtp server with properties {server name:"smtp.gmail.com", user name:email_address, uses ssl:true, authentication:password, password:myPass} 


    --Attach SMTP server 
    set smtp server of newacct to addsmtp 
    delay 1.0 
    tell application "System Events" to tell process "Mail" 
     set frontmost to true 
     keystroke return 
    end tell 

    --Mailbox Sync 
    delay 0.5 
    on return 
    tell application "Mail" 
     synchronize with account mailboxname 
    end tell 

end try 
end tell 

Example

回答

1

您可以通過,如果一個表(在你的情況下,輸入密碼)被打開檢查等待密碼輸入:

tell application "System Events" 
    tell process "Mail" 
     repeat until exists sheet 1 of window 1 
      delay 0.1 
     end repeat 
    end tell 
end tell 
1

我對這個有一天開始工作以及。 據我所知,你應該和我有同樣的問題。 當你告訴腳本來設置新的SMTP服務器時,必須聲明

「身份驗證:密碼」

的問題是,這是很簡單的錯誤。 如果您在AppleCode中檢查郵件庫,它會聲明「身份驗證」是「密碼」後綴的正確前綴。

儘管如此,它每次都會引發錯誤。

我看不到任何工作在一分鐘,也沒有人曾經嘗試過。 Majorly垃圾

2

有一種變通方法:

set authentication to ("axct" as constant)

set authentication to password 
代替
相關問題