Re: export multiple emails as PDF
Re: export multiple emails as PDF
- Subject: Re: export multiple emails as PDF
- From: iKel via AppleScript-Users <email@hidden>
- Date: Mon, 29 Aug 2022 22:34:54 -0500
Hello Deivy,
thanks for your solution; it worked well. I modified it to do it by
sender. Not sure how to go about the repeat statement as you suggest but I did
manage to get something to work the only thing is I have to manually save it
before it opens up another email. I could probably get it to click save before
it opened up the next email. Feel free if you have any suggestions to improve
this.
here is the code:
tell application "Mail"
activate
--iterate over items within the mailbox
set msgs to get (every message of mailbox "INBOX" of account "Google"
whose sender contains "Kell")
set msg to item 1 of msgs
end tell
tell application "System Events"
set frontmost of process "Mail" to true
repeat with msg in msgs
tell process "Mail"
open msg
tell menu bar 1 to tell menu "File" to tell menu item
"Export as PDF…" to click
delay 2
end tell
end repeat
end tell
> On Aug 29, 2022, at 9:42 AM, Deivy Petrescu <email@hidden> wrote:
>
>
>
>> On Aug 25, 2022, at 14:40, email@hidden wrote:
>>
>> Hello Deivy, I will give that try. Thanks for your help!
>> On Aug 24, 2022, 1:33 PM -0500, Deivy Petrescu <email@hidden>,
>> wrote:
>>>
>>>
>>>> On Aug 23, 2022, at 12:17, iKel via AppleScript-Users
>>>> <email@hidden> wrote:
>>>>
>>>> Hello!
>>>> I am trying to automate some of my email processes. I am sure I can do
>>>> some of what I want to do with Smart Folders but does anyone have any good
>>>> scripts for email? The main thing right now I am wanting to do is to
>>>> select or retrieve multiple emails and export as PDF and drop it in a
>>>> folder or maybe a note app like Notion. Is there a way to convert multiple
>>>> emails to PDF? I have a working a script but at the moment I need to
>>>> figure out how to grab a specific sender and perhaps loop over all the
>>>> emails by that sender and then export as a PDF. I am not sure if I am even
>>>> heading in the right direction. If anyone has better solutions feel free
>>>> to provide them! I appreciate it!
>>>>
>>>> tell application "Mail"
>>>> activate
>>>> —iterate over items within the mailbox
>>>> set msgs to item 1 of (get every message of mailbox "INBOX" of account
>>>> "Google" whose sender contains "")
>>>> tell application "System Events"
>>>> tell application process "Mail"
>>>> repeat with msg in msgs
>>>> -- or save as a link
>>>> click menu item "Export as PDF…" of menu "File" of menu bar 1
>>>> --place in folder or note app
>>>> end repeat
>>>> end tell
>>>> end tell
>>>> end tell
>>>> _______________________________________________
>>>
>>> Hi,
>>> I believe your script will work.
>>> However, I’d suggest you open the message (open msgs) and remove the repeat.
>>> In your code you say item 1 of (), so you will get only one item.
>>> I’d also consider writing :
>>>
>>> "set msgs to contents of item 1 of”
>>>
>>> I haven’t tried the script yet.
>>>
>>> Best, be safe, wear mask, get vaccinated and keep social distance.
>>>
>>> Deivy Petrescu
>>> email@hidden
>
> Hello Kel,
> I have this script that works correctly.
> Note however, that I checked messages by date, because the list of messages
> to check is longer, and it takes more time to run it.
> Also, I used your script as basis and took only the first message of the
> bunch.
> If you want to go to all, you would have to use a repeat statement and a
> System Events action on the Finder window.
> Here it is:
>
> <script>
> set yesterday to (current date) - 1 * days
> --return yesterday
> tell application "Mail"
> activate
> --iterate over items within the mailbox
> set msgs to (get every message of mailbox "INBOX" of account "Gmail"
> whose date received > yesterday)
> set msg to item 1 of msgs
> open msg
> end tell
> tell application "System Events"
> set frontmost of process "Mail" to true
> tell process "Mail"
> tell menu bar 1 to tell menu "File" to tell menu item "Export
> as PDF…" to click
> end tell
> end tell
> </script>
>
>
>
> Best, be safe, wear mask, get vaccinated and keep social distance.
>
> Deivy Petrescu
> email@hidden
>
>
>
>
>
>
_______________________________________________
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