How Do I Copy 6 Fields of Text From an Email & Paste Into My Notes App?

I'm quite new to KM, so I'm looking for a workflow to automate the following...

I regularly receive an email form my clients complete with all their details. There are about 6 different fields. I'd like to somehow copy this text and then paste it into a note on my Notes app.

Can anyone walk me through the most efficient way of automating this??

EDIT: Attached is a screenshot of a sample form I've created for reference....

You want to extract only those fields and leave the rest, right?

This will come down to how the email is formatted. I assume you don't want to post an exact email example, but maybe you can you post a redacted version? Try to replicate the structure

Well, I guess it depends on what automation you want and how you want to paste, what, where. If you want to keep it simple, just use KM Clipboard Manager. First copy all 6 fields, then open the C-Manager

and paste your fields. You can paste all together in a row (select all) or one by one. Some apps even allow you to copy all fields at once.

When I am dealing with emails that come in a reliable format, such as contact form inquiries and order confirmations, I use mostly Type a Keystroke and Select or Show a Menu Item actions.

For example, If the incoming message has:

Name: John Doe
Email John@Doe.com

I'll search for "Name: " then keystroke to the end of the line and copy, then save the clipboard as a variable.

Does that give you something to work with? Happy to go further into the weeds :slight_smile:

Ahh, yes. This method could work too. Thank you!

Do you mind venturing into the weeds a bit further? :blush: I think I can fumble my way through the searching part but I haven’t worked with variables before yet so no idea what to do there, or then how to paste these into the Notes app.

Thank you so much for your time :pray::pray:

I'm quite new to KM, so I'm looking for a workflow to automate the following...

I regularly receive an email form my clients complete with all their details. There are about 6 different fields. I'd like to somehow copy this text and then paste it into a note on my Notes app.

Can anyone walk me through the most efficient way of automating this??

EDIT: Attached is a screenshot of a sample form I've created for reference....

1 Like

Are you using Mail.app? If so, I think it should be doable in this format.

Replying to the message (without sending) should put your cursor in the body of the message. From there, you can count how many times you down arrow to get to Fred Smith. You'll need that many keystroke actions. Then you can shift-command-right arrow to select the entire name. That's your next keystroke action. Command-C to Copy would be next. Then you can use a Set Variable to Text action with %SystemClipboard% and now you'll have the Partner 1 Full Name as a variable.

I think this will work if the data is always in the exactly the same place. Beyond that, you could use Find in Mail.app for a static word or phrase in the message and then keystroke actions from there.

The sounds hacky, but I use this approach on several otherwise-tedious messages I process regularly and it works great for me. (You'll need to adjust for the appropriate keystrokes, but I think you can get there with some trial and error)

Yes, I use the mail app. Great. I can definitely do this, thank you!! I'll repeat this process 7 times since there are 7 fields that need to be copied.

And then what about the pasting side of things into my Notes app?? I haven't had any experience with variables / clipboards yet.

Okay. I guess it depends how you want them to show up in Notes. Each time you copy a field from Mail to the clipboard, you can set it as a variable in KM like this:


The variable will remain available to other macros. So if you wanted to insert varFullName from the above example into a note where the cursor is positioned, you can do this:

You can get fancier from there. For example, you could compose the entire contents of the note as a new variable based on the previous variables, and then paste that into Notes:

There are more advanced ways to handle the Note end of things, but that might be something to consider after you feel more comfortable with Keyboard Maestro.

Looks good. Only thing to add would be switching to Notes.

Open Notes with the 'Activate a Specific Application' action, Start a new note (Type a Keystroke (Cmd+N)), give it a title (Insert Text by typing), and hit Return.

From there you're in the note body and ready to use the variables as @evanfuchs showed. Might be easier to use the 'Insert Text By Pasting' action with evan's formatting example – unless you need to save the body as a whole

Also, keep in mind you may want to insert pause actions in between some of those actions in case it's going too fast.

There are more sophisticated ways to wait but this is simple enough to hard code it.

1 Like

Amazing! Thanks so much for giving me your time & your helpful advice @kraftyDevil and @evanfuchs :slight_smile:

2 Likes

Hey @lammers01,

Select your email and then run this AppleScript in Apple's Script Editor.app.

tell application "Mail"
   set selectedMessageList to selection
   if selectedMessageList ≠ {} then
      set selectedMessage to item 1 of selectedMessageList
      tell selectedMessage
         set mailText to its content
         
         return mailText
         
      end tell
   end if
end tell

Let me know what result you get.

-Chris

Hey, Chris.

Your AppleScript approach here is way more simple than using Keystroke actions. Do you know of a way to get a message's html content (or the entire body with images, similar to Select All + Copy)? I see that the content property is rich text, but maybe another way?

@evanfuchs,

You could use "source" instead of "content", which is the same as Mail's "View"->"Message"->"Raw Source" command, but then you'd have to extract the HTML section, parse the content, etc.

But the simplest way would be to do just as you say -- open the message, "Select All", copy, switch to Notes, make a new Note, and paste -- and (ab)use the fact that, when you open an email, "Select All" does indeed act on the body of the email. Should be doable with KBM keystroke actions or AppleScript Process Suite events.

Depending on what you are trying to achieve, Mails's "Export as PDF..." may also be useful.

Nige is right – you can get the source – but that does not give you RTF or RTFD content. It's all HTML.

Extracting styled text from that mess is not too difficult using the command line utility textutil, but pulling images could get “fun”...

It's not really rich-text – Mail is lying... (Bad Apple!)

-Chris

1 Like

Seems like continuing to use select all + copy is the best route. Thanks

Sorry about the slow reply @ccstone This is the result I got....

"

More clients.
Less admin.

Your questionnaire has been completed.
This is an automated email to let you know that your questionnaire for Test Job has been completed. Bravo!

PARTNER 1 FULL NAME
Fred Smith
PARTNER 1 EMAIL
fred@test.com
PARTNER 1 BEST CONTACT NUMBER
123456789
PARTNER 1 HOME ADDRESS
1 Test Avenue, Testville, Australia, 9999
PARTNER 2 FULL NAME
Mary Jane
PARTNER 2 BEST CONTACT NUMBER
987654321
PARTNER 2 EMAIL
mary@test.com

Click here to review the answers to your questionnaire for Test Job
Regards,
The Team @ SN

Okay, run that AppleScript from an Execute an AppleScript action and save the result to a variable.

From there it's pretty easy to parse – particularly if the output format is always the same.

Holler if you need help with the parsing.

1 Like

Hi @evanfuchs,

Sorry for the delayed reply with this, but thank you so much for your explanation! You've really helped a lot, so again, huge thanks :pray:

I seem to have my head around everything, except for the pasting of these variables. I've attached a screenshot showing my Notes app template I've setup that I'd like to paste these variables into....

I guess my confusion is around the placement of these variables. As you can see I require varEmail1 in two different locations. How would I achieve this, as well as pasting the other variables in the correct position?

(I think your fancier suggestion is what will work best for me, however for educational purposes I'm keen to know how I would implement this using suggestion 1).

No problem.

I'm not sure I understand the question and I only see varEmail1 in one location in your screenshot, but if you have the variables stored for each contact and you are looking to place them step-by-step along with the text as shown in your screenshot rather the "fancier" (read: better) method of formatting the text block in KM first, you could:

Insert text by pasting Email:
Type a Keystroke Tab
Insert text by pasting %Variable%varEmail1%
Type a Keystroke Return
Insert text by pasting Address:

…and so on. Then move on to your next contact with the corresponding variables.