Macro for email extraction and forward/reply

I am a KM newbie. I have a particular task in front of me (about 300 student emails to respond to), and I was hoping to use KM to automate the process. Here's what's going on.

The emails are forwarded from an address I don't care about, but in the body of the email the students have left their actual email address (I'll copy an example of what I a talking about below with my own email address inserted to protect the student's privacy).

Manually, I need to click "forward" on these emails (because I don't want to reply to the "info@xxxxx.com" address, I want to eventually send to the student address at the bottom). Then I go and copy the email address they inserted at the bottom (in this case, wbarnes4393@gmail.com), and paste that into the "mail to" field. Then, I will manually type my response.

I have tried to set up a macro that forwards the email, tabs down and to the bottom and selects the text with JUST the student email at the bottom in it (skipping past my school email (wbarnes@law.tamu.edu), the "info@xxxxx.com", and the "xxxxx@gmail.com," then CMD-C to copy that selected text, then does a RegEx search for the email address, and sets the result to a variable I called "email address"

After this, I am stuck in my ignorance of how KM and variables work. All I want to do is stick that email address (that has been populated into the "email address" variable) into the main "Mail To" field, then tab back down to the body field so the first manual steps I take are to type in the body of the now repopulated, forwarded email properly addressed to the student email address.

I've attached the macro I have done so far. I'm not sure if it's correct or not, and even if it is, I don't know how to go forward and manipulate the variable into the mailto field.

I would be grateful for any guidance!!!

Wayne


(start body of forwarded email)

(excuse the brevity, Iā€™m replying to a whole lot of these - also, reply further to wbarnes@law.tamu.edu or I may not get your reply!)

Wayne Barnes | Professor of Law
School of Law | Texas A&M University
ph: 817.212.4109 | wbarnes@law.tamu.edu
SSRN| law.tamu.edu

Begin forwarded message:

From: info@xxxxxxxxxxx.com
Subject: Live At Home - Wayne Barnes
Date: July 9, 2020 at 1:29:37 PM CDT
To: xxxxxxxxxxxx@gmail.com

For the common law gap filling of price, is the reasonable value for the services determined at the time of delivery, established by the K, like it is in the UCC? Or reasonable price at some other time? wbarnes4393@gmail.com

Kaplan replies.kmmacros (5.6 KB)

Try this:
Kaplan replies.kmmacros (5.8 KB)

Thank you for sharing all these details about what your goal is and the way you've been trying to go about it, as well as properly anonymized sample email text. Sharing details like that makes helping other people with their macros much easier. While you could automate creating these emails the way you've been doing, I'm happy to tell you that KM contains lots of actions and tokens for working with Mail that makes a task like this much faster and more reliable. This macro I put together should

  • automatically search the body text of the currently selected email for the student's email address without needing to simulate tabbing down and copying it to the clipboard
  • create a new Mail message with the student's address, subject, and body text already filled out
  • bring the new message window to the front and waits until it's frontmost to tab down to the body field

Kaplan replies 1.1.kmmacros (5.0 KB)

It does this by using the %MailContents% and %MailSubject% tokens, which capture the currently selected email's body text and subject automatically, and the Send Mail Message action. Feel free to post again with any further questions you might have.

2 Likes

@gglick really outdid me there! :wink:

1 Like

Thank you so much to both of you! I will go try this out shortly!