Thanks ShaneOn 30 May 2015, at 11:57 am, Shane Stanley < email@hidden> wrote: On 30 May 2015, at 11:24 am, Brian Christmas < email@hidden> wrote: I tried for 3 hours last night, but noting worked with the GUI addressing to outgoing message, either front or 1, or get id.
But for sending you don't need to use GUI scripting. Have you tried using Mail's send command with outgoing message 1?
tell application "Mail" try send outgoing message 1 end try end tell tell application "Mail" tell outgoing message 1 try send end try end tell end tell
They (and variations), don’t work. Outgoing messages are immune to interference from the system. However, as you say this method is in use by some groups, I thought there must be a way of doing what I require. Hopelessly hopeful is the way I think I’d describe my thoughts.
It’s essential that one attachment, a company logo, go at the front (top) of the message. The others I can add at the end, then add 4 blank lines, then add again, I thought?
No. I mean, you can place them where you like in the attributed string -- but when you pass it to Mail it moves all the attachments to the end. You have no control over that part of the process.
As I've said before, you're using the wrong tool. You're building an app for commercial use, but you keep trying to build it around a free email app with a broken scripting implementation.
Ahhh, now I understand.
Would you mind posting code that you used to add the attachments, please. I can’t work out how, and would like to experiment. Nothing better to do.
Sure, here's the relevant snippet:
-- make NSURL set anNSURL to current application's |NSURL|'s fileURLWithPath:attachmentPosixPath -- make file wrapper from URL set anNSFileWrapper to current application's NSFileWrapper's alloc()'s initWithURL:anNSURL options:0 |error|:(missing value) -- make attachment from file wrapper set anNSTextAttachment to current application's NSTextAttachment's alloc()'s initWithFileWrapper:anNSFileWrapper -- make attributed string from attachment set theAttAttachment to current application's NSAttributedString's attributedStringWithAttachment:anNSTextAttachment
And then later:
-- insert attributed string containing attachment anNSMutableAttributedString's insertAttributedString:theAttAttachment atIndex:0
That inserts it at the beginning, but it still ends up at the end. And you get a large preview image, rather than a small icon and label -- Mail treats all attachments included this way as if they are pictures. There may be some way around the latter problem, but I doubt that there's any way to stop Mail moving them to the end.
Seriously, there are other email apps out there that are relatively cheap and get good reviews. As far as I can see, their scripting implementations fall short too. But some of them are written by enthusiastic developers, and they have a tough battle surviving in competition with a free app, no matter how bad the freebie is. Find one that is otherwise fine, and press them to implement what you want to see available via scripting. Offer them some money, and the prospect of expanding their market by becoming the scripter's choice. Shop around. Collate the wishes posted here and elsewhere, and offer to be a conduit for serious testing. You may not get a bite, but you might also find someone who is happy to do it, but just needs some guidance. After all, you say you have nothing better to do...
I’d have to ask my clients if they want to change email clients. They have many years of store emails in the Mail app. The time saving is amazing, but may not be worth it.
Unless there’s someone who’s reading this knows how to implement my requirements, I think I’ll revert back to ‘ make outgoing message'
Regards, and thanks once more.
Santa |