attachment to desktop script stopped working

 tell application "Microsoft Outlook"
	set selectedMsg to (current messages)
	set selectedMsg to item 1 of result
	set msgAttachment to attachments of selectedMsg
	set msgAttachment to result's item 1
	
	set attachmentName to name of msgAttachment
	set attachmentFile to ((path to desktop) & attachmentName) as text
	
	--> save message to disk before we open it
	save msgAttachment in attachmentFile
end tell


The above script worked fine for years. It all of a sudden stopped working. I get error 2700. it now hangs on save msgAttachment in attachmentFile

No idea as to why and I seem to not be able to fix it.

I am on OS10.12.6 and outlook 2011.

Try :

 set p2d to path to desktop as text # speak to Standard Additions so must be out of tell application block.
 tell application "Microsoft Outlook"
	set selectedMsg to (current messages)
	set selectedMsg to item 1 of result
	set msgAttachment to attachments of selectedMsg
	set msgAttachment to result's item 1
	
	set attachmentName to name of msgAttachment
	set attachmentFile to p2d & attachmentName # EDITED
	
	--> save message to disk before we open it
	save msgAttachment in attachmentFile
end tell

or

 tell application "Microsoft Outlook"
	set selectedMsg to (current messages)
	set selectedMsg to item 1 of result
	set msgAttachment to attachments of selectedMsg
	set msgAttachment to result's item 1
	
	set attachmentName to name of msgAttachment
	tell me to set attachmentFile to ((path to desktop as text) & attachmentName) # EDITED
	
	--> save message to disk before we open it
	save msgAttachment in attachmentFile
end tell

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi 11 mars 2019 09:26:06

Thanks Yvan, nice to see you are still active in this forum, and thanks.

Sorry to say both generate the same error.

HI.

Since attachmentFile is only an HFS path, does it work if you change the ‘save’ line to this?

save msgAttachment in file attachmentFile -- NB. 'file' specifier.

Nope Nigel, same error.

May you insert a log instruction to check what is really used as file name ?

  set attachmentName to name of msgAttachment
   log attachmentName # ADDED
   tell me to set attachmentFile to ((path to desktop as text) & attachmentName) # EDITED

Maybe the file specifier must be edited as:

tell me to set attachmentFile to attachmentFile as «class furl» # ADDED
save msgAttachment in attachmentFile

or, as you are working with a M…osoft application it may be useful to create the file before saving in it:

tell me to set attachmentFile to attachmentFile as «class furl» # ADDED
do shell script "touch " & quoted form of (POSIX path of attachmentFile) # ADDED
save msgAttachment in attachmentFile

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi 11 mars 2019 13:49:56

Thanks.

On your first suggestion I get:
i
Result:
error “Microsoft Outlook got an error: An error has occurred.” number -2700[/i]

on the second I get:
i
Result:
error “Microsoft Outlook got an error: Can’t get file (file "OS E:Users:e:Desktop:csv-2019-Week11-09:33:59.gz").” number -1728 from file (file “OS E:Users:e:Desktop:csv-2019-Week11-09:33:59.gz”)[/i]

and the third as in two.

csv-2019-Week11-09:33:59.gz is the correct name of the enclosure.

I am puzzled, as it used to work for years.

Your enclosure has colons in its name. That could be part of the problem.

Indeed that is it. The original is without colons, but somehow the email process changes it to colons. I have now changed the Terminal command that sends it from the server to use ‘-’ and not ‘/’ (this becomes ‘:’ in the email). The ‘-’ works.

I say thank you to you all.