ã¿ã¤ãã«éãã
Â
èæ¯
Macã®Mailæ å ±ãPythonã§å¦çããããã以ä¸ãã¹ããåç §ã«emlxããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«ã
ãã¹ãããã¦ããã³ã¼ããèµ°ããããglobã®æ®µéã§å ¨ãemlxãã¡ã¤ã«ãå¼ã£ããããªãã
macos - API for programmatically accessing mail in Python on mac os X - Stack Overflow
Â
ããã§ã¯emlxãåå¼·ãã以åã®åé¡ã
ãã¡ããã¡ã試ãã¦ãããã¡ã«ç´ã£ãã®ã§ä¸è¦ãªæé ããããããããªããã以ä¸ã§è§£æ±ºã
ã»ãã¥ãªãã£ã«é¢ãã¦ã¯éå¤æ¼¢ãªã®ã§ã権éå¤æ´çã¯èªå·±è²¬ä»»ã§ã
Â
1) Terminal, spyderã« Full Disk Accessãä»ä¸
System settings -> Privacy & Security -> Full Disk Accessãããã®äºã¤ããªã³ã
Terminalã¯2)ã§ãã¡ã¤ã«æ¨©éãå¤ããå¾ã¯æããæ»ãã¦ãOKã
Spyderã使ã£ã¦ãªããã°å½ç¶ãã¡ãã¯ä¸è¦
Â
2) Mailã®ãã¡ã¤ã«æ¨©éãå¤æ´
chmod 775 /Users/<username>/Library/MailÂ
注1: <username>ã¯èªåã®ãã®ã«å¤æ´ã
注2: ã¾ãç¡ãã¨æãããMailã§éããã£ã¬ã¯ããªã使ç¨ãã¦ããå ´åã¯é©å®å¤æ´
注3: permission deniedãåºãã sudo chmod 775 /Users/<username>/Library/Mail ã§ã
Â
3) Spyderããªã¹ã¿ã¼ã
PCãªã¹ã¿ã¼ãã®æ¹ãç¡é£ãã
Â
確èª
以ä¸ãæ¸ã¾ããã以ä¸ã®ãã¹ãã³ã¼ãã§ç¢ºèªã
注1: <username>ã¯èªåã®ãã®ã«å¤æ´ã
Â
import glob
i = 0
for name in glob.iglob('/Users/<username>/Library/Mail/**/*.emlx', recursive = True) :
  print(name)
  i += 1
  if i > 10 :
    break
Â
ãã¡ã¤ã«ãã¹ãããªã³ããããã°OKã
Â
æ¤ç´¢ãã¦ãå ¨ã解決æ¹æ³ãåºã¦ããªãã£ãã®ã§ãããããSonomaã®full disk accessé¢é£ã®å¤æ´ã«èµ·å ããåé¡ã ã¨æ¨å¯ã
Â
Â
使ç¨ç°å¢
Mac OS X (Sonoma 14.2.1)
Spyder (Python 3.8)
Â
Â
Â
Â
Â