Wednesday, March 20, 2019

#1 2019-03-11 01:51:23 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 225

attachment to desktop script stopped working

Applescript:

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.

Offline

 

#2 2019-03-11 02:26:30 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 3367

Re: attachment to desktop script stopped working

Try :

Applescript:

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

Applescript:

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

Offline

 

#3 2019-03-11 02:39:36 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 225

Re: attachment to desktop script stopped working

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

Sorry to say both generate the same error.

Offline

 

#4 2019-03-11 05:14:18 am

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 4823

Re: attachment to desktop script stopped working

HI.

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

Applescript:

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


NG

Offline

 

#5 2019-03-11 06:07:12 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 225

Re: attachment to desktop script stopped working

Nope Nigel, same error.

Offline

 

#6 2019-03-11 06:50:08 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 3367

Re: attachment to desktop script stopped working

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

Applescript:

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:

Applescript:

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:

Applescript:

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

Offline

 

#7 2019-03-11 07:24:04 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 225

Re: attachment to desktop script stopped working

Thanks.

On your first suggestion I get:
(*csv-2019-Week11-09:33:59.gz*)
Result:
error "Microsoft Outlook got an error: An error has occurred." number -2700



on the second I get:
(*csv-2019-Week11-09:33:59.gz*)
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")


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.

Offline

 

#8 2019-03-11 07:31:56 am

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 4823

Re: attachment to desktop script stopped working

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


NG

Offline

 

#9 2019-03-11 08:08:46 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 225

Re: attachment to desktop script stopped working

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.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)