I’m trying to add two attachments, and a pasted image of a Numbers Document Chart, into an email.
The Chart has to go first, as one of the attachments is a compressed copy of the Numbers Document, which is saved and compressed after the Chart is copied.
Trouble is, the Chart image is added after the last paragraph, along with extra single space lines, then the compressed attachment is added, after either the last paragraph, or the last attachment. In either case, the added attachment is replacing the pasted Chart.
I’ve tried all sorts of things, but it is always replaced.
The attachment before the first paragraph works OK.
Anyone know what’s wrong, and how I can fix it please? I’ve spent 10 hours playing around with it, to no avail.
Santa.
# Paste copied Numbers Chart
try
set p to 7
if (my numbersGraphPrint) then
# set (my numbersGraphPrint) to false
set p to 8
my setUpTallyNumbersChartCreator() # Sets up & copies Chart
tell current application to delay 2
tell application "Mail"
activate
tell application "System Events" to tell process "Mail"
# In case cursor is in top address fields
repeat 7 times
keystroke tab
tell current application to delay 0.2
end repeat
keystroke return
set p to 9
keystroke (ASCII character 31) using command down # move to end of text
tell current application to delay 0.1
keystroke return
keystroke " "
keystroke return
keystroke " "
keystroke return
set p to 10
tell application "Mail" to activate
set p to 10.1
try
set p to 10.2
keystroke "v" using command down
keystroke return
set p to 10.3
tell current application to delay 1
end try
end tell
end tell
end if
if my RunForOz then tell current application to delay 20 # image is being pasted
end try
try
set PosixFilePath to ""
if (my numbersGraphIncludeCompressedFile) and ("Hourly" is not in my itemDetails) then
set p to 11
tell application "Finder"
activate
set p to 12
select file (my saveTheFilePath)
end tell
set p to 13
tell current application to delay 0.2
tell application "System Events" to tell process "Finder"
set p to 14
click menu item "Compress" of menu 1 of menu bar item 3 of menu bar 1
set p to 15
set compressedFilePath to ((my saveTheFilePath as text) & ".zip" as text) as text
set p to 16
tell application "Finder"
repeat until exists file compressedFilePath
tell current application to delay 0.1
end repeat
set p to 17
set PosixFilePath to POSIX path of (compressedFilePath as text)
end tell
end tell
end if
end try
set p to 20
# Insert Attachments
tell application "Mail"
tell newMessage
set p to 6.1
try
repeat with themailitem in theCCRecipients
make new to recipient at end of to recipients with properties {address:themailitem}
end repeat
end try
try
make new attachment with properties {file name:PosixLogoPath as POSIX file} at before the first paragraph
on error errmsg number errnum
tell application "System Events" to display dialog "eMailIt setting Logo error " & errmsg & " number " & errnum
end try
set p to 18
if PosixFilePath ≠ "" and (my displayHourlyJobsFlag) then
try
tell application "System Events" to tell process "Mail"
keystroke (ASCII character 31) using command down # move to end of text
tell current application to delay 0.1
keystroke return
keystroke " "
keystroke return
end tell
make new attachment with properties {file name:PosixFilePath as POSIX file} at after the last attachment # OR, paragraph
if my RunForOz then tell current application to delay 20 # replaces image
on error errmsg number errnum
tell application "System Events" to display dialog "eMailIt setting compressed File error " & errmsg & " number " & errnum
end try
set p to 19
end if
end tell
end tell