2014-09-30 77 views
0

我想更改当前撰写的邮件的内容,并在末尾添加字符串*WF*。下面是脚本,我得到一个错误Microsoft Outlook got an error: Can’t set content of draft window id 9490 to ...在outlook中更改新邮件的内容

on replace_chars(this_text, search_string, replacement_string) 
    set AppleScript's text item delimiters to the search_string 
    set the item_list to every text item of this_text 
    set AppleScript's text item delimiters to the replacement_string 
    set this_text to the item_list as string 
    set AppleScript's text item delimiters to "" 
    return this_text 
end replace_chars 

tell application "Microsoft Outlook" 

    activate 

    set theWindow to window 1 

    -- check it's really draft 
    if class of theWindow is not draft window then 
     display dialog "Not a draft" 
     return 
    end if 

    -- save the draft 
    save theWindow 

    --get the id of the object of the draft window 
    set myObjectID to id of (object of theWindow) 

    -- to make it secure 
    set myContent to content of message id myObjectID 

    --edit recipient 
    -- set theBCC to bcc recipient of message id myObjectID 
    -- set emailString to theBCC 
    make new bcc recipient at message id myObjectID with properties {email address:{name:"Ittay Dror", address:"[email protected]"}} 

    set myContent to my replace_chars(myContent, "</body>", "*WF*</body>") 
    set the content of theWindow to myContent 
end tell 

回答

0

你不能设置窗口的内容。请将邮件的内容:

set the content of message id myObjectID to myContent 

干杯, 迈克尔/汉堡

+0

但随后的窗口中的内容保持不变。有没有办法从消息中读取? – IttayD 2014-09-30 09:46:18

+0

**在最后**结束之前关闭窗口** 告诉**保存内容。我没有找到任何其他方式...如果你想对消息做其他事情,你可以用 **打开消息ID myObjectID ** – ShooTerKo 2014-09-30 10:21:52