Automatic Custom Email Response.

Hello,

I have been digging around the web and this site for many hours looking for a solution to my problem. I have found some scripts that come close or touch on parts of what I need. In theory what im trying to do seems simple but from what i can see it may be. I am hope to get some assistance for anyone willing to help.

Scope.

  1. I receive emails from a ticketing system (many of them). I am required to acknowledge every ticket.
  2. the incoming email has allot of information but I only need one piece the “Incident ID:”
  3. this Incident ID is present in both the subject and the body I dont care where I pull it from
  4. the acceptance process is not done by replying but by clicking a “mailto” link in the email
    looking at this link it is simple. it opens a new email and inputs a specific email address in the to field. adds the same generic one liner to the body. then it adds the words "Acknowledge Incident (IM####) where #### is the incident number.

I have seen plenty of example scripts that will create the email i need address the to field and fill the body even the subject. but my problem is how do I get that one unique incident ID at the end of the subject line.

I have explored a couple of option.

  1. if posible I would like a rule in mail.app to launch the applescript. when the email tickets arrive.
    Unknown: can the script pull the Incident ID from the subject or body then create a new email and place the Incident Id in the correct place at the end of the subject line. then send it.

option two. Since there is a perfectly working "mailto"link in the original email. can an applescript pull that url. and launch it. opening an new mail window with all the proper information already filled then send it.

one more approve. may be over kill but I am up for anything.
somehow have the rule run the applescript that exports the body of the new email to a text file. then creates a new email and somehow reads the “incident ID” from the text file. then sends the email.

I know this is allot for a simple tasks. I get about 100 of these email a night. and if I dont respond to them within 10 minutes. higher ups get paged. and that looks bad on me.

Ideally I would like to leave my mac on and mail.app up and it does all this without any interaction from me.

good luck :slight_smile:

Thanks in advance.

P.S. If this post is in the wrong place, I am sorry, Please direct me to the proper place.

T

Hi,

here is a starting point for you:

property IDOffset : "Incident ID:"

tell application "Mail"
	set theMessage to selection
	repeat with this_message in theMessage
		set message_subject to subject of this_message
		if message_subject contains "Incident ID:" then
			set myoffset to offset of IDOffset in message_subject
			set IDNumber to text (myoffset + (count of characters of IDOffset)) thru end of message_subject
			display dialog "Acknowledge Incident (IM" & IDNumber & ")"
		end if
	end repeat
end tell

run this script from the Editor with one of ticketing emails selected. If the subject of the email contains “Incident ID:” then it will extract the number from after the string.

To help any further I would probably need to see one of the emails and if you would like any further help then feel free to PM me.

Hope this helps,
Nik

WOW,

This looks great… to be able to pull the ID from the subject… I will play with this tonight. I am at work and they make me use a windows computer :frowning: but all the real work is done on my Mac at home. I will let you know how it goes.
Thank you so much for taking the time to put this together.

Tom