• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Fwd: 'Make new attachment' dilemma
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fwd: 'Make new attachment' dilemma


  • Subject: Fwd: 'Make new attachment' dilemma
  • From: Brian Christmas <email@hidden>
  • Date: Tue, 26 May 2015 14:16:47 +1000

G’day

Yvan, I had a brainwave (which is rare for me), and have tried adding the Numbers Graph as an attachment, instead of pasting it in. Partially works.



Further to my saving Attachments’ problem, I’ve discovered several interesting but perplexing things about Mail and Attachments.


1. If you add an attachment, and delay for more than a short while, the cursor moves to the ‘To:’ field automatically.

2. If you go to the end of the existing text, count the paragraphs, then add immediately extra paragraphs, and immediately count them, the newly added paragraphs are not recognised by Mail.

3. If  you execute point 2, and then add an attachment ‘to after the last paragraph’, it adds the attachment after the last OLD paragraph.

4. If you add an attachment, then immediately add another, with just a short delay, the second attachment is attached immediately after the first, even if you use ‘to after the last paragraph’.

5. If you execute point 4, but with a lengthy delay, the first attachment(s) is replaced by the second one.

6. If you add extra paragraphs, and wait several seconds, the new paragraphs are recognised, but adding a new attachment erases the others.



This leaves me with a quandary, how can I add an extra attachment several paragraphs AFTER the first attachment.

I think two points need addressing.

a) How can I move the cursor to the content field window (NOT the address fields), without using Tabs?

b) How can I add, and fix, extra paragraphs to the content field window, without waiting a long delay?

If anyone’s got the answers, I’d appreciate learning about them.

Regards

Santa

property saveTheFilePath : ((path to desktop) & "MM Numbers Chart Files:   Weekly Tally (Current Week):2015 5 (May) 25 Saved 2015 525 20 59 28 Weekly Tally (Current Week).numbers" as text)

my setUpMessage()

on setUpMessage()
tell application "Mail"
activate
set p to 4
set the_content to ("test" & return & "test test" & return & return & return & return & return as rich text)


set newMessage to make new outgoing message with properties {visible:true, subject:"test", content:the_content}
set compressedFilePath to ((my saveTheFilePath as rich text) & ".zip" as rich text) as rich text
set x to 0
tell application "Finder"
repeat until exists file compressedFilePath
set x to x + 1
tell current application to delay 0.1
if x > 40 then
say "file does not exist"
exit repeat
end if
tell current application to delay 0.1
end repeat
set PosixFilePath to POSIX path of (compressedFilePath as text)
end tell
my setUpTallyNumbersChartCreator()
tell application "Finder"
set jpgFilePath to ((path to desktop) & "Numbers Chart.jpg" as text)
set PosixjpgFilePath to POSIX path of (jpgFilePath as text)


end tell
activate
tell application "System Events" to tell process "Mail"
set frontmost to true # ADDED for Yosemite
# In case cursor is in top address fields
repeat 7 times
keystroke tab
tell current application to delay 0.2
end repeat
keystroke return
tell current application to delay 0.2
set p to 9
tell newMessage
set c to count of paragraphs
end tell
say c # says '7'
keystroke (ASCII character 31) using command down # move to end of text
tell current application to delay 0.1
repeat 4 times
keystroke return
keystroke "test1"
keystroke (ASCII character 31) using command down # move to end of text
end repeat
keystroke (ASCII character 31) using command down # move to end of text
end tell
tell newMessage
make new attachment with properties {file name:PosixjpgFilePath as POSIX file} at after the last paragraph
# OR, attachment


make new attachment with properties {file name:PosixFilePath as POSIX file} at after the last attachment
end tell
tell current application to delay 2 # allows the cursor to move back to 'To:' field
tell application "System Events" to tell process "Mail"
set frontmost to true # ADDED for Yosemite
repeat 7 times
keystroke tab
tell current application to delay 0.2
end repeat
keystroke return
keystroke (ASCII character 31) using command down # move to end of text
# tell current application to delay 10.2
tell newMessage
set c to count of paragraphs
end tell
say c # says '8'
repeat (c + 6) times
keystroke (ASCII character 31) using command down
keystroke return
keystroke "test2."
end repeat
tell newMessage
set c to count of paragraphs
end tell
say c # says '8'
end tell
tell newMessage
tell current application to delay 1
# This adds attachment just before last 'test2', but adding it removes the first two attachments
make new attachment with properties {file name:PosixFilePath as POSIX file} at after the last paragraph
end tell
tell newMessage
set c to count of paragraphs
end tell
say c # says '7'
end tell
end setUpMessage


on setUpTallyNumbersChartCreator()
tell application "Numbers"
activate
tell document 1
tell current application to delay 0.2
tell sheet 1
set width of chart 1 to (width of chart 1)
tell current application to delay 0.2
tell application "System Events" to tell process "Numbers"
click menu item "Copy" of menu 1 of menu bar item "Edit" of menu bar 1
end tell
tell current application to delay 1
end tell
end tell
# quit saving no
end tell
tell application "Preview"
activate
tell current application to delay 0.4
tell application "System Events" to tell application process "Preview"
set nbw to count windows
(* Trigger the menu item "File > New from Clipboard" *)
keystroke "n" using {command down}
(* Wait the availability of the new PDF window *)
repeat while nbw = (count windows)
delay 0.2
end repeat
(* Get the name of the new window *)
set WindowName to name of window 1 --(first window whose subrole is "AXStandardWindow")


keystroke "s" using {command down}
(* Wait the availability of the Save sheet *)
repeat until exists sheet 1 of window WindowName
delay 0.2
end repeat
tell sheet 1 of window WindowName
-- properties of every UI elements
tell group 1
click first pop up button
delay 0.2
-- properties of every menu item of menu 1 of first pop up button
click menu item "JPEG" of menu 1 of first pop up button
delay 0.2
end tell -- group
delay 0.4
keystroke "Numbers Chart"
click pop up button 1
click menu item "Desktop" of menu 1 of pop up button 1
delay 0.2
click button 1 (* Click in the Save button *)
delay 0.2
try
click button 1 of sheet 1 # 'Replace' button
end try
delay 1 # Allow time to save before closing
end tell -- sheet
end tell -- System Events
close window 1 saving no


end tell
end setUpTallyNumbersChartCreator

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: 'Make new attachment' dilemma
      • From: Christopher Stone <email@hidden>
References: 
 >Re: 'Make new attachment' dilemma (From: Brian Christmas <email@hidden>)

  • Prev by Date: Re: 'Make new attachment' dilemma
  • Next by Date: Re: 'Make new attachment' dilemma
  • Previous by thread: Re: 'Make new attachment' dilemma
  • Next by thread: Re: 'Make new attachment' dilemma
  • Index(es):
    • Date
    • Thread