Tom
I developed zemailwithattachments long ago in Panorama 6 by adding a front end to Dave’s excellent “Mail w attachments” channel code.
I’ve been using a modified version for some years, zemailattachments, which is enclosed. I can’t remember what I changed from zemailwithattachments (and don’t have time right now to check) but it is working fine for me every day in Panorama X and should solve your problem. It uses the same parameters as the original.
David Duncan
/*
This statement sends a single email to one or more recipients with attachments if specified. The statement has four parameters which can be in the form of constants or variables or formulas or a mixture of these. Attachments are deleted after emailing.
The procedure has four parameters. All can be in the form of constants or variables or a mixture of these.
PARAMETER(1) - EMAIL RECIPIENT
"someone@someisp.url" e-mail address of recipient (may be repeated for multiple recipients)
PARAMETER(2) - SUBJECT
"topic" (if missing use "no subject")
PARAMETER(3) - ATTACHMENTS
File name of attachment (may be repeated for multiple attachments). Must be on the desktop.
If attachments not required, leave parameter space empty
PARAMETER(4) - MESSAGE BODY
*/
local eRecipients,eSubject,eAttachments,eOptions,lAttachmentName,lTrashFileList,
eTo,eCC,eBCC,eBody,eResult,errorOptions,dropFolder,dropDisk,eMessage,eFileName,eListAttachments,X,Y,Z
eRecipients=replace(replace(parameter(1)," ",""),","," ")
eSubject=parameter(2)
eAttachments=parameter(3)
arrayfilter eRecipients,eRecipients," ","to="+import()
arrayfilter eAttachments,eAttachments,",","attachment={"+folderpath(info("desktopfolder"))+import() +"}"
eAttachments=replace(eAttachments,","," ")
lTrashFileList=parameter(3)
eBody=parameter(4)
//[--Are attachment files available?--]
X=0
Loop
X=X+1
lAttachmentName=array(parameter(3),X,",")
Y=0
Loop
Y=Y+1
If Y>10 //…takes about 35 seconds before giving up
AlertOK "File '"+lAttachmentName+"' is not available on the Desktop, so it cannot be sent in an email"
Stop
Endif
If arraysearch(listfiles(info("DesktopFolder"),""),lAttachmentName,1,¶)=0 // is it on the Desktop yet?
Superalert ||Waiting for output of ||+¶+||"||+lAttachmentName+||" to appear on the Desktop||, {height=130 width=260 buttons="OK" timeout="3"}
Endif
Until arraysearch(listfiles(info("DesktopFolder"),""),lAttachmentName,1,¶)>0
Until X=extract(parameter(3),",",-1)
eOptions=
eRecipients+" "+"subject={"+eSubject+"} "+eAttachments
//displaydata eOptions
/* This section actually sends the e-mail. The procedure has two parameters:
PARAMETER(1) - EMAIL OPTIONS
This parameter must contain assignments for various e-mail options, including
the recipient, sender, subject, server, etc.
smtp="mail.myisp.url" address of SMTP server (optional, if missing use default value)
From="x@xx.url" e-mail address of sender (optional, if missing using default value)
FromName="My Name" name of sender (optional, if missing use default value, if any)
To="someone@someisp.url" e-mail address of recipient (may be repeated for multiple recipients)
cc="someone@someisp.url" e-mail address of carbon copy recipient (may be repeated for multiple recipients)
bcc="someone@someisp.url" e-mail address of blind carbon copy recipient (may be repeated for multiple recipients)
Subject="topic" (if missing use "no subject")
Attachment="Full:Path:and:File Name" full path and file name of attachment (may be repeated for multiple attachments)
errormessage=on/off/yes/no/true/false - if on/yes/true display error message if problem and stop, otherwise
place error message in global variable ChannelResult. If ChannelResult match "Sent*" then e-mail was sent ok.
PARAMETER(2) - MESSAGE BODY
*/
eTo=tagparameterarray( eOptions, "to=" , ¶ )
if eTo <> ""
ArrayFilter eTo,eTo,¶,“make new to recipient at end of to recipients with properties {address:”+applescriptstring(array(eTo,seq(),¶))+“}”
endif
eCC=tagparameterarray( eOptions, "cc=" , ¶ )
if eCC <> ""
ArrayFilter eCC,eCC,¶,“make new cc recipient at end of cc recipients with properties {address:”+applescriptstring(array(eCC,seq(),¶))+“}”
endif
eBCC=tagparameterarray( eOptions, "bcc=" , ¶ )
if eBCC <> ""
ArrayFilter eBCC,eBCC,¶,“make new bcc recipient at end of bcc recipients with properties {address:”+applescriptstring(array(eBCC,seq(),¶))+“}”
endif
eSubject=tagparameter(eOptions,"subject=",1)
if eSubject=""
eSubject="(no subject)"
endif
eAttachments=tagparameterarray( eOptions, "attachment=" , ¶ )
eListAttachments=""
if eAttachments <> ""
ArrayFilter eAttachments,eAttachments,¶,applescriptstring(import())
eAttachments="{"+replace(eAttachments,¶,", ")+"}"
eListAttachments=“set theAttachments to ” + eAttachments + “
set theseFiles to {}
repeat with thisFile in theAttachments
set the end of theseFiles to alias thisFile
end repeat”
else
eListAttachments=“set theseFiles to {}”
endif
executeapplescript “try”+¶+eListAttachments+“
tell application "Mail"
set newMessage to make new outgoing message with properties {subject:”+applescriptstring(eSubject)+“, content:”+applescriptstring(eBody)+“}
tell newMessage
”+eTo+¶+eCC+¶+eBCC+“
tell content
repeat with thisAttachment in theseFiles
make new attachment with properties {file name:thisAttachment}
end repeat
end tell
end tell
”+?(eAttachments <> "","delay 1"+¶,"")+
“send newMessage
end tell
set scriptResult to "Sent"
on error errMsg number errNum
set scriptResult to "Error: " & errMsg & "(" & errNum & ")"
end try
return scriptResult”
eResult=AppleScriptResult
if eResult match {"*"}
eResult=replace(replace(eResult[2,-2],{\"},{"}),{\\},{\}) /* AppleScript puts quotes around returned text values and escapes " and \ */
endif
//displaydata eResult
if eResult=""
eResult="AppleScript did not compile."
endif