I have been trying to figure out how to copy an attachment from an incoming message in outlook to a new outgoing message through applescript.
The code below is what I've got so far, but it's definitely wrong. Outlook throws and error at me stating: "Microsoft Outlook got an error: Can’t make missing value into type file."
tell application "Microsoft Outlook"
-- get the incoming message
set objMessage to item 1 of (get current messages)
set myMessage to make new outgoing message
-- iterate through attachments
-- for each attachment make a new attachment in the message to send identical properties
-- ???
repeat with _attachment in attachments of objMessage
set n to name of _attachment
set ct to content type of _attachment
set f to file of _attachment
set fs to file size of _attachment
tell myMessage
make new attachment with properties {name:n, content type:ct, file:f, file size:fs}
end tell
end repeat
open myMessage
end tell
I've tried a couple of other things, but I can't seem to get at the file property of the incoming messages attachment.
Does anybody have any experience working with files in Outlook and Applescript in this way?
Dylan
It appears that just passing the attachment between messages doesn't work but saving the attachment first and then passing the file name to the
file
property for the new attachment does.Note 1: You will probably want to add logic to remove the files (original attachments) that were saved from the incoming message.
Note 2: Another option would be to find the location of the file from the incoming message and just use that alias instead of saving them first just to add them to the outbound message'