diff --git a/misc/mail-notify b/misc/mail-notify index ad897b0..259dfba 100755 --- a/misc/mail-notify +++ b/misc/mail-notify @@ -12,13 +12,13 @@ val icon = "/usr/share/icons/Adwaita/48x48/actions/mail-message-new.png" val cacheFile = envPath("XDG_CACHE_HOME", os.home/".cache") / "seen-mails" val maildir = envPath("MAILDIR", os.home/"Mail") - case class MailInfo(from: String, subject: String, mailbox: String) object MailInfo { def fromPath(p: os.Path, maildir: os.Path) = { val msg = readMessage(p) + val address = msg.getFrom.head.asInstanceOf[InternetAddress] MailInfo( - msg.getFrom.head.asInstanceOf[InternetAddress].getPersonal.replace("&", "&"), + Option(address.getPersonal).map(_.replace("&", "&")).getOrElse(address.getAddress), msg.getSubject.replace("&", "&"), (p/up/up relativeTo maildir).toString )