0
votes

I want to create an Applescript that when clicked on, replies a selected mail and adds a specific Message as the content:

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". 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.

2

2 Answers

0
votes

The main problem appears to be an Outlook issue of not allowing a change to the content once a message is open.

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.

0
votes

Thanks for the help 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