简体   繁体   English

Applescript Outlook-设置回复内容

[英]Applescript Outlook - setting content of reply

I want to create an Applescript that when clicked on, replies a selected mail and adds a specific Message as the content: 我想创建一个Applescript,当单击该Applescript时,它会答复选定的邮件并添加特定的Message作为内容:

This part is working: 这部分正在工作:

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

But when I write this: 但是当我写这个:

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

The content of the original message that I wanted to reply to is replaced by that "Hello". 我要回复的原始邮件的内容已替换为“ Hello”。 I haven't been able to find one single example to put me in the right direction. 我一直找不到一个例子来说明我正确的方向。

I took the reply part from another topic, but there isn't one that mentions the content with this format, in other formats I have been able to add the content, but not the reply part. 我从另一个主题获取了答复部分,但是没有人提到这种格式的内容,在其他格式中,我可以添加内容,但是没有答复部分。

Thanks for the help. 谢谢您的帮助。

The main problem appears to be an Outlook issue of not allowing a change to the content once a message is open. 主要问题似乎是Outlook问题,即一旦打开邮件,不允许更改内容。

The script below deals with this by opening it after changes are made. 下面的脚本通过在进行更改后将其打开来处理此问题。

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

I have also distinguished between html and plain text variants as you may have to approach them differently. 我还区分了html和纯文本变体,因为您可能不得不以不同的方式来对待它们。

Thanks for the help adamh! 感谢您的帮助adamh!

This is the solution: 这是解决方案:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM