I'm very new to apple scripts, and honestly am not too much of a programmer. I want to do something very similar to this: How can I determine whether or not a contact with a given e-mail address exists in the Address Book? Except I want to look through all my emails, and search for specific addresses (i have a list of thousands in csv/excel/numbers format), to see whether any email communication exists. I figured out how to run through my list and search, but not sure how to return whether mail exists. I often double email people with marketing material and would rather not do that. Here's my basic search script that pulls from numbers, just need to figure out how to ask the mail application if a mail item exists after running each email search through it.
set {eAddress} to getData()
repeat with i from 1 to 4
activate application "Mail"
tell application "System Events"
tell process "Mail"
tell window 1
keystroke "f" using {command down, option down}
keystroke {item i of eAddress} as string
end tell
end tell
end tell
end repeat
on getData()
set colA to {}
tell application "Numbers"
activate
tell table 1 of sheet 1 of document 1
#set lastRow to 4
set lastRow to row count
#first row index of (get end (last cell of column 1) direction toward the top)
repeat with i from 2 to lastRow
set end of colA to (value of cell i of column "A")
end repeat
end tell
end tell
return {colA}
end getData