2013-12-12 15 views
0

我想創建一個AppleScript對點擊時的設置內容,回覆選定的郵件,並添加特定的信息作爲內容:AppleScript的展望 - 回覆

這部分工作:

tell application "Microsoft Outlook" 
    set replyMessage to selection 
    set replyMessageSubj to subject of replyMessage 
    reply to replyMessage with opening window 
end tell 

但是,當我寫這個:

tell application "Microsoft Outlook" 
    set replyMessage to selection 
    set replyMessageSubj to subject of replyMessage 
    reply to replyMessage with opening window 
    set content of replyMessage to "Hello" 
end tell 

我想回復的原始郵件的內容被替換爲「你好」。 我一直無法找到一個例子來讓我走向正確的方向。

我從另一個主題回答了部分內容,但是沒有一個提到這種格式的內容,其他格式中我已經能夠添加內容,但沒有回覆部分。

感謝您的幫助。

回答

0

感謝您的幫助adamh!

這是解決方案:

tell application "Microsoft Outlook" 
set replyToMessage to selection 
set mymessage to "Aqui se trapeo con jerga" 
set OldContent to content of replyToMessage 
if (replyToMessage is "") then 
    log ("NOTHING SELECTED!") 
    return 
end if 
set replyMessageSubj to subject of replyToMessage 
set replyMessage to reply to replyToMessage without opening window 
if has html of replyMessage then 
    log ("HTML!") 
    set the content of replyMessage to "Hello World<br> This is an HTML test<br><br><br><hr>" & OldContent 
else 
    log ("PLAIN TEXT!") 
    set the content of replyMessage to "Hello World<br> This is a plain text test <br><br><br><hr>" & OldContent 
end if 
open replyMessage 
end tell 
0

主要問題似乎是一個Outlook問題,一旦消息打開,就不允許更改內容。

下面的腳本通過在更改後打開它來處理此問題。

tell application "Microsoft Outlook" 
    set replyToMessage to selection 
    if (replyToMessage is "") then -- nothing selected, don't continue 
     log ("NOTHING SELECTED!") 
     return 
    end if 
    set replyMessageSubj to subject of replyToMessage 
    set replyMessage to reply to replyToMessage without opening window 

    if has html of replyMessage then 
     log ("HTML!") 
     set the content of replyMessage to ("<p>Hello, how are you?</p><br />" & the content of replyMessage) 
    else 
     log ("PLAIN TEXT!") 
     set the plain text content of replyMessage to "Hello, how are you?" & return & (the plain text content of replyMessage) 
    end if 

    open replyMessage -- may not need to do this, you could just send it 

end tell 

我也區分了html和純文本變體,因爲您可能需要以不同的方式處理它們。

+0

感謝您的幫助,但是這一次是打開收到的郵件,並修改其上的文字。這不是創建一個新的回覆信息。 – Age

+0

@年齡不錯,我已經刪除了收到的消息的內容,我的錯誤我認爲這就是你想要的。再次嘗試代碼。 – adamh

+0

幾乎完成!但是,是的,我確實希望將收到的郵件的內容包含在回覆中,以前版本的問題在於它在原始郵件上添加了回覆文本,而不是回覆。我真的很驚訝它可以做到這一點。 – Age