Hello all -
I'm trying to configure a pair of scripts in Outlook to allow me to add a comment to an email (e.g. describing subsequent non-email discussions on that topic) and then modify those comments. The script to add comments works perfectly, but the script to modify them - which needs to be able to parse the original message, separate out the comment header, the comment, and the message itself - is failing with an -1708 Error. This appears to be Outlook-specific, in that if I run the script outside of outlook and manually specify the content of the message to be run, the script works perfectly. It only fails inside of Outlook:
I've excised the portion after the "extractBetween" call, since that is the point of failure and my code after that point is still a bit of a mess as I haven't been able to troubleshoot it to get it working. Is there any reason the extractBetween function is failing only in Outlook? Does Outlook not like running custom functions?
Thanks!
I'm trying to configure a pair of scripts in Outlook to allow me to add a comment to an email (e.g. describing subsequent non-email discussions on that topic) and then modify those comments. The script to add comments works perfectly, but the script to modify them - which needs to be able to parse the original message, separate out the comment header, the comment, and the message itself - is failing with an -1708 Error. This appears to be Outlook-specific, in that if I run the script outside of outlook and manually specify the content of the message to be run, the script works perfectly. It only fails inside of Outlook:
Code:
to extractBetween(SearchText, startText, endText)
set tid to AppleScript's text item delimiters -- save them for later.
set AppleScript's text item delimiters to startText -- find the first one.
set endItems to text of text item -1 of SearchText -- everything after the first.
set AppleScript's text item delimiters to endText -- find the end one.
set beginningToEnd to text of text item 1 of endItems -- get the first part.
set AppleScript's text item delimiters to tid -- back to original values.
return beginningToEnd -- pass back the piece.
end extractBetween
tell application "Microsoft Outlook"
-- get the currently selected message or messages
set selectedMessages to current messages
-- if there are no messages selected, warn the user and then quit
if selectedMessages is {} then
display dialog "Please select a message first and then run this script." with icon 1
return
end if
repeat with theMessage in selectedMessages
-- get the information from the message, and store it in variables
set theName to subject of theMessage
set theCategory to category of theMessage
set theContent to content of theMessage as text
set t to theContent
set currentComment to extractBetween(t, "Comment:<br>", "<br>⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯<br><br>") --> Should return current comment
end repeat
end tell
I've excised the portion after the "extractBetween" call, since that is the point of failure and my code after that point is still a bit of a mess as I haven't been able to troubleshoot it to get it working. Is there any reason the extractBetween function is failing only in Outlook? Does Outlook not like running custom functions?
Thanks!