2016-02-01 66 views
0

我正在嘗試回覆電子郵件,並希望根據已知事實(包括他們的電子郵件地址爲[email protected])包含我正在響應的人的名字。Applescript Outlook以獲取電子郵件的名稱

這裏是我到目前爲止,但似乎無法得到的電子郵件地址或名稱:

on run 
tell application "Microsoft Outlook" 
    set replyToMessage to selection 
    if (replyToMessage is "") then 
     -- no email selected, don't continue 
     display dialog "No email is selected!" 
     return 
    end if 
    set theRecpt to extract name from sender of replyToMessage as text 
    set replyMessageSubj to subject of replyToMessage 
    set replyMessage to reply to replyToMessage without opening window 

    --need variable theName to get name or email to parse here 

    if has html of replyMessage then 
     log "HTML!" 

     set the content of replyMessage to ("<p>Hi " & theName & ",<br><br>This is my email body 
    else 
     log ("PLAIN TEXT!") 
     set the plain text content of replyMessage to "Hi " & theName & " 
     This is my email body" & return & (the plain text content of replyMessage) 
    end if 
    open replyMessage -- may not need to do this, you could just send it 
end tell 
end run 

任何幫助,將不勝感激。

更新:我已經試過這樣:

 set sender's address of newMessage to "[email protected]" 

我收到以下錯誤:

Microsoft Outlook got an error: Can’t make address of sender of outgoing message id 292223 into type specifier. 

回答

4

嘗試:

tell application "Microsoft Outlook" 
    set replyToMessage to selection 

    if replyToMessage = missing value then 
     -- no email selected, don't continue 
     display dialog "No email is selected!" 
     return 
    end if 

    set theName to name of (get replyToMessage's sender) 
    set replyMessageSubj to replyToMessage's subject 
    set replyMessage to reply to replyToMessage without opening window 

    if has html of replyMessage then   
     log "HTML!" 
     set the content of replyMessage to ("<p>Hi " & theName & ",<br><br>This is my email body ") 
    else 
     log ("PLAIN TEXT!") 
     set the plain text content of replyMessage to "Hi " & theName & " 
       This is my email body" & return & (the plain text content of replyMessage) 
    end if 
    open replyMessage 
end tell 
+1

我從來沒有想過要對使用撇號小號發件人以及獲取。我在哪裏可以找到該文檔?然後,我使用: 將名稱設置爲(get replyToMessage的發件人)的地址 將AppleScript的文本項目分隔符設置爲{「。」} 以獲取名字。任何想法如何將首字母的首字母大寫? – shayster01

相關問題