Export Phone Numbers With Apple Mail or Gmail

He gets hundreds of messages with the content (photo). How can I copy phone numbers from all these messages?

Hey @kamilek,

Select an appropriate message in Apple mail and then run this AppleScript in Apple's Script Editor.app:

tell application "Mail"
   set selectedMessageList to selection
   if selectedMessageList ≠ {} then
      set selectedMessage to item 1 of selectedMessageList
      tell selectedMessage
         return content
      end tell
   end if
end tell

If you get appropriate output from your message then you can use Keyboard Maestro to run the AppleScript and parse the output.

-Chris

It works well, but the data is from 1 messages. And how to do it from a few. For example, those marked

You can work with selected messages in mail like this:

property LF : linefeed
property messageSeperator : "••••••••••"

set messageContentAggregator to {}

tell application "Mail"
   set selectedMessageList to selection
   if selectedMessageList ≠ {} then
      
      repeat with theMessage in selectedMessageList
         set selectedMessage to item 1 of selectedMessageList
         tell selectedMessage
            set end of messageContentAggregator to content & LF & messageSeperator
         end tell
      end repeat
      
   end if
end tell

return messageContentAggregator as text