**I'm working on this script to send messages to all the phone numbers from a csv that's how I formatted the csv **
Phone Number,Message
+16478xxxxx,Hi this is a test text me back if you have received it
+14164xxxxx,Hi this is a test text me back if you have received it
+12263xxxxx,Hi this is a test text me back if you have received it
on run {input, parameters}
set csvFilePath to POSIX path of (path to desktop as text) & "contacts.csv"
-- Read CSV file
set contactsData to readCSV(csvFilePath)
-- Loop through each row (phone number & message)
repeat with contact in contactsData
set {targetBuddyPhone, targetMessage} to contact
-- Open Messages manually to avoid issues
tell application "Messages" to activate
delay 2
-- Use AppleScript shell command to send message
set sendCommand to "osascript -e 'tell application \"Messages\" to send \"" & targetMessage & "\" to buddy \"" & targetBuddyPhone & "\"'"
do shell script sendCommand
delay 2
end repeat
return input
end run
-- Function to Read CSV
on readCSV(csvPath)
set contactsList to {}
set csvData to do shell script "cat " & quoted form of csvPath
set csvLines to paragraphs of csvData
repeat with i from 2 to count of csvLines -- Skip header row
set rowData to item i of csvLines
set rowValues to split(rowData, ",")
if (count of rowValues) ≥ 2 then
set end of contactsList to {item 1 of rowValues, item 2 of rowValues}
end if
end repeat
return contactsList
end readCSV
-- Function to Split Text by Delimiter
on split(inputText, delimiter)
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to delimiter
set outputList to text items of inputText
set AppleScript's text item delimiters to oldDelim
return outputList
end split
im getting this result what's going on can't understand im pretty new to this
error "" number -1721
iMessages is running in the background