Keyboard Maestro “Extract FirstName, FamilyName, Organization and Email From Sender” Macro

Keyboard Maestro “Extract FirstName, FamilyName, Organization and email from sender” Macro

The macro works on the Sender of a mail, which may be in 'friendly' format
e.g. Peter N Lewis {peter@stairways.com.au}
or just the email address alone (peter@stairways.com.au). In this second case, the macro tries to derive the person's name and their organization directly from email address

It has its imperfections and I welcome any improvements, particularly to the regex.

Extract FirstName- FamilyName- Organization and email from sender.kmmacros (7.5 KB)

3 Likes

Thats great! Use it to answer mails to address someone.

1 Like

This is a really useful and powerful script, but I'm getting a lot of empty returns on everything except the derived names, especially on my university's Exchange server, where most return addresses have the form:

From: "Surname, F.H. (Firstname)" <f.h.Surname@university.edu>

On an email with this address, this macro returns:

  • FullName: blank
  • FirstName: H
  • FamilyName: Surname
  • Email: h.surname@university.edu

Any thoughts on how I can tweak this to return, as FullName: "Firstname Surname"?

1 Like

Having changed jobs, my daily machine now runs Windows and so I am no longer making regular use of my macros!

The RegEx for this macro assumes email addresses in the form
firstname.lastname@domain.xxx

and it also supports
firstname@domain.xxx

Your university’s model

x.y.lastname@domain.xxx

includes an extra full stop (or period) that I didn’t envisage and you will need to adapt the RegEx accordingly

Thanks! I even have colleagues with 3 or for initials.

So, I can just add another sequence of ([A-Za-z0-9]*?)_?\ – I assume?

((['-a-zA-Zàáâäãéèêëîïíôöòóûüùú])[ ](['-a-zA-Zàáâäãéèêëîïíôöòóûüùú][ ]['-a-zA-Zàáâäãéèêëîïíôöòóûüùú])[ ]?(['-a-zA-Zàáâäãéèêëîïíôöòóûüùú])?)?<?(([A-Za-z0-9]?)_?.([A-Za-z0-9]?)?.([A-Za-z0-9]*?)?.?([A-Za-z0-9]+)_?@([A-Za-z-])?.?([A-Za-z-]).[A-Za-z.]{2,6})>?