Apple Intelligence now features Image Playground, Genmoji, Writing Tools enhancements, seamless support for ChatGPT, and visual intelligence.

Apple Intelligence has also begun language expansion with localized English support for Australia, Canada, Ireland, New Zealand, South Africa, and the U.K. Learn more >

You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Extract emails to a spreadsheet

Am I able to extract all the emails in my mailbox into a file? I would like the email addresses of those who contacted me


MacBook, macOS 10.15

Posted on Oct 11, 2021 1:44 PM

Reply
Question marked as Top-ranking reply

Posted on Oct 11, 2021 2:08 PM

Thanks to Barney 15E & DSM...


Opened up AppleScript Editor (once I sussed out what it was)


Now this was new to me as I had never even looked at Applescript because as quoted on the net :

You can fit the people that love applescript in a small car or even a bike..

Anyway thats about as much as I can tell you about applescript..

I now have the email stored in a mailbox inside my INBOX.

This is the script I then used to get the results into Microsoft Excel:

tell application “Microsoft Excel”

set LinkRemoval to make new workbook

set theSheet to active sheet of LinkRemoval

set formula of range “D1” of theSheet to “Message”

set formula of range “C1” of theSheet to “Subject”

set formula of range “B1” of theSheet to “From”

set formula of range “A1” of theSheet to “Date”

end tell

 

tell application “Mail”

set theRow to 2

set theAccount to “Sales”

get account theAccount

set theMessages to messages of inbox

repeat with aMessage in theMessages

my SetDate(date received of aMessage, theRow, theSheet)

my SetFrom(sender of aMessage, theRow, theSheet)

my SetSubject(subject of aMessage, theRow, theSheet)

my SetMessage(content of aMessage, theRow, theSheet)

set theRow to theRow + 1

end repeat

end tell

 

on SetDate(theDate, theRow, theSheet)

tell application “Microsoft Excel”

set theRange to “A” & theRow

set formula of range theRange of theSheet to theDate

end tell

end SetDate

 

on SetFrom(theSender, theRow, theSheet)

tell application “Microsoft Excel”

set theRange to “B” & theRow

set formula of range theRange of theSheet to theSender

end tell

end SetFrom

 

on SetSubject(theSubject, theRow, theSheet)

tell application “Microsoft Excel”

set theRange to “C” & theRow

set formula of range theRange of theSheet to theSubject

end tell

end SetSubject

 

on SetMessage(theMessage, theRow, theSheet)

tell application “Microsoft Excel”

set theRange to “D” & theRow

set formula of range theRange of theSheet to theMessage

end tell

end SetMessage

Run the script and after a minute (depending on amount of messages) your excel sheet is complete.


Export Messages From Mail to Excel With AppleScript | Blog |DSM Design

4 replies
Question marked as Top-ranking reply

Oct 11, 2021 2:08 PM in response to Ferray

Thanks to Barney 15E & DSM...


Opened up AppleScript Editor (once I sussed out what it was)


Now this was new to me as I had never even looked at Applescript because as quoted on the net :

You can fit the people that love applescript in a small car or even a bike..

Anyway thats about as much as I can tell you about applescript..

I now have the email stored in a mailbox inside my INBOX.

This is the script I then used to get the results into Microsoft Excel:

tell application “Microsoft Excel”

set LinkRemoval to make new workbook

set theSheet to active sheet of LinkRemoval

set formula of range “D1” of theSheet to “Message”

set formula of range “C1” of theSheet to “Subject”

set formula of range “B1” of theSheet to “From”

set formula of range “A1” of theSheet to “Date”

end tell

 

tell application “Mail”

set theRow to 2

set theAccount to “Sales”

get account theAccount

set theMessages to messages of inbox

repeat with aMessage in theMessages

my SetDate(date received of aMessage, theRow, theSheet)

my SetFrom(sender of aMessage, theRow, theSheet)

my SetSubject(subject of aMessage, theRow, theSheet)

my SetMessage(content of aMessage, theRow, theSheet)

set theRow to theRow + 1

end repeat

end tell

 

on SetDate(theDate, theRow, theSheet)

tell application “Microsoft Excel”

set theRange to “A” & theRow

set formula of range theRange of theSheet to theDate

end tell

end SetDate

 

on SetFrom(theSender, theRow, theSheet)

tell application “Microsoft Excel”

set theRange to “B” & theRow

set formula of range theRange of theSheet to theSender

end tell

end SetFrom

 

on SetSubject(theSubject, theRow, theSheet)

tell application “Microsoft Excel”

set theRange to “C” & theRow

set formula of range theRange of theSheet to theSubject

end tell

end SetSubject

 

on SetMessage(theMessage, theRow, theSheet)

tell application “Microsoft Excel”

set theRange to “D” & theRow

set formula of range theRange of theSheet to theMessage

end tell

end SetMessage

Run the script and after a minute (depending on amount of messages) your excel sheet is complete.


Export Messages From Mail to Excel With AppleScript | Blog |DSM Design

Extract emails to a spreadsheet

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.