iCal Gmail OSX Repeated Email Workaround Solution

The Problem

Using iCal, Gail Calendars, Syncing with OSX Mail (Big Sur), Email alerts are duplicated many times.

The bug/Issue has been unaddressed by Google/Apple for many years now and many users have multiple Alerts appearing in their inboxes.
This seems to occur mostly with reoccurring Anointments but not always.

The problem is illustrated below;


The above all arriving on the same day (at a similar time)

The Solution/Workaround

This automation script solution takes the subject and date of any incoming message and compares it with the next 10 emails in your inbox, it flags and removes the incoming message to the Trash automatically if the same message already exists. Its a cheat workaround  but a great timesaver. You can change the code to make it the next 50 email etc if you wish.

The code currently flags the message so you can run this code for sometime until you are satisfied it works (TEST Mode), then simply uncomment the TRASH line of code to activate it for future messages (effectively going LIVE). See the code for details.

Shown below the messages are flagged that would be trashed.


This workaround has been tested on the following hardware / OS Version


Procedure / Info

1) 

Using the Apple Script Editor, Create a program with the code detailed below. Name the program "iCal Issue Fix.scpt"

2) 

Save the script file to the following folder (this is very important, else the service will not find the file).

Under your User / Library find the following location;




3) 

In OSX Mail create a rule as follows, linking the script to all incoming messages


TIP : If you cant see the Script file in the 'Run Apple Script' drop down, then yu may have placed the file in the wrong folder.

4)

When clicking OK .... if you get the following, click Apply




Program code / AppleScript

tell application "Mail"

--Code    : Darren Gosnell, darrengosnell@gmail.com. Updated 20210825

--Purpose : A Gmail or Apple Mail bug exists when using iCal events

--             Events are emailed to the recipient repeatedly, and there is 

--             no know reliable fix. The purpose of this code is to check if a 

--             email has been recently received (eg and event email notification)

--             and then disallow the new email to be repeated in the INBOX (by

--             removing it to TRASH.

--             The code matching below looks for Received Date, given all Events 

--             would be received on the same day, and Subject - given Subjects would 

--             be the same for an Calendar event notifications.

--Variables / Config

set MyMailAccount to "darrengosnell@gmail.com"

set MessageScopeCheck to 10 ## new messages

-- Get the initial message comparison vars

set theMessage to message 1 of mailbox "INBOX" of account MyMailAccount

subject of theMessage

-- Grab the Subject and DateComponent of the inbound email

set cSubject to subject of theMessage

set cDateReceived to date received of theMessage

set cDateReceived to short date string of (cDateReceived)

-- Step though from message 2 to MessageScopeCheck messages (ie check older messages)

repeat with iEmailCounter from 2 to MessageScopeCheck

-- Grab the Subject and DateComponent of the older emails

set theOlderMessage to message iEmailCounter of mailbox "INBOX" of account MyMailAccount

subject of theOlderMessage

set cOlderSubject to subject of theOlderMessage

set cOlderDateReceived to date received of theOlderMessage

set cOlderDateReceived to short date string of (cOlderDateReceived)

--debug code -- display dialog the cOlderDateReceived & ":" & cDateReceived

-- Compare the incoming message with the older ones

if cOlderSubject = cSubject and cOlderDateReceived = cDateReceived then

-- We have an existing message, so we set the flag on incoming one and put it

-- in trash, because we already have it

repeat with s in theMessage

--Leave next line in for testing until you are happy

--this solution is flagging the correct messages

set flag index of s to 2 as integer

--uncomment this next line when yu are ready

--for this solution to start moving incoming

--repeats to the trash

--set mailbox of theMessage to mailbox "Trash"

do shell script "echo " & cSubject

end repeat

do shell script "echo " & cDateReceived

else

-- do nothing

end if

end repeat

end tell

No comments:

Post a Comment