PyEmailerAJM 1.2__tar.gz → 1.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyEmailerAJM
3
- Version: 1.2
3
+ Version: 1.4
4
4
  Summary: Allows for automating sending Email with the Outlook Desktop client. Future releases will add more client support
5
5
  Home-page: https://github.com/amcsparron2793-Water/PyEmailer
6
6
  Author: Amcsparron
7
7
  Author-email: amcsparron@albanyny.gov
8
8
  License: MIT License
9
- Download-URL: https://github.com/amcsparron2793-Water/PyEmailer/archive/refs/tags/1.2.tar.gz
9
+ Download-URL: https://github.com/amcsparron2793-Water/PyEmailer/archive/refs/tags/1.4.tar.gz
10
10
  Keywords: Outlook,Email,Automation
11
11
  Platform: UNKNOWN
12
12
  License-File: LICENSE.txt
@@ -4,7 +4,8 @@ PyEmailerAJM.py
4
4
 
5
5
  install win32 with pip install pywin32
6
6
  """
7
- from os.path import isfile, abspath, isabs, join
7
+ from os import environ
8
+ from os.path import isfile, abspath, isabs, join, isdir
8
9
 
9
10
  # imports
10
11
 
@@ -20,8 +21,14 @@ class EmailerNotSetupError(Exception):
20
21
 
21
22
 
22
23
  class PyEmailer:
24
+ # the email tab_char
25
+ tab_char = ' '
26
+ signature_dir_path = join((environ['USERPROFILE']),
27
+ 'AppData\\Roaming\\Microsoft\\Signatures\\')
28
+
23
29
  def __init__(self, display_window: bool,
24
30
  send_emails: bool, logger: Logger = None,
31
+ email_sig_filename: str = None,
25
32
  auto_send: bool = False,
26
33
  email_app_name: str = 'outlook.application'):
27
34
 
@@ -51,6 +58,37 @@ class PyEmailer:
51
58
  self._logger.error(e, exc_info=True)
52
59
  raise e
53
60
 
61
+ self._email_signature = None
62
+ self.email_sig_filename = email_sig_filename
63
+
64
+ @property
65
+ def email_signature(self):
66
+ return self._email_signature
67
+
68
+ @email_signature.getter
69
+ def email_signature(self):
70
+ signature_full_path = join(self.signature_dir_path, self.email_sig_filename)
71
+ if isdir(self.signature_dir_path):
72
+ pass
73
+ else:
74
+ try:
75
+ raise NotADirectoryError(f"{self.signature_dir_path} does not exist.")
76
+ except NotADirectoryError as e:
77
+ self._logger.warning(e)
78
+ self._email_signature = None
79
+
80
+ if isfile(signature_full_path):
81
+ with open(signature_full_path, 'r', encoding='utf-16') as f:
82
+ self._email_signature = f.read().strip()
83
+ else:
84
+ try:
85
+ raise FileNotFoundError(f"{signature_full_path} does not exist.")
86
+ except FileNotFoundError as e:
87
+ self._logger.warning(e)
88
+ self._email_signature = None
89
+
90
+ return self._email_signature
91
+
54
92
  def _GetReadFolder(self, email_dir_index: int = 6):
55
93
  # 6 = inbox
56
94
  self.read_folder = self._mapi_ns.GetDefaultFolder(email_dir_index)
@@ -83,7 +121,8 @@ class PyEmailer:
83
121
  self._logger.error(e, exc_info=True)
84
122
  raise e
85
123
 
86
- def FindMsgBySubject(self, subject: str, forwarded_message_match: bool = True) -> list:
124
+ def FindMsgBySubject(self, subject: str, forwarded_message_match: bool = True,
125
+ reply_msg_match: bool = True) -> list:
87
126
  """Matches the message.Subject string to the subject attr string and returns a list of messages.
88
127
  If forward_message_match is True than messages are matched without
89
128
  regard to if they start with 'FW:' or 'FWD:'"""
@@ -96,6 +135,11 @@ class PyEmailer:
96
135
  (message.Subject.startswith('FWD:')
97
136
  and message.Subject.split('FWD:')[1].strip() == subject)):
98
137
  matched_messages.append(message)
138
+ if reply_msg_match:
139
+ if (message.Subject == subject or
140
+ (message.Subject.startswith('RE:')
141
+ and message.Subject.split('RE:')[1].strip() == subject)):
142
+ matched_messages.append(message)
99
143
  else:
100
144
  if message.Subject == subject:
101
145
  matched_messages.append(message)
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyEmailerAJM
3
- Version: 1.2
3
+ Version: 1.4
4
4
  Summary: Allows for automating sending Email with the Outlook Desktop client. Future releases will add more client support
5
5
  Home-page: https://github.com/amcsparron2793-Water/PyEmailer
6
6
  Author: Amcsparron
7
7
  Author-email: amcsparron@albanyny.gov
8
8
  License: MIT License
9
- Download-URL: https://github.com/amcsparron2793-Water/PyEmailer/archive/refs/tags/1.2.tar.gz
9
+ Download-URL: https://github.com/amcsparron2793-Water/PyEmailer/archive/refs/tags/1.4.tar.gz
10
10
  Keywords: Outlook,Email,Automation
11
11
  Platform: UNKNOWN
12
12
  License-File: LICENSE.txt
@@ -0,0 +1,15 @@
1
+ # <u>PyEmailerAJM</u>
2
+ ### <i>Makes automating Outlook emails quick and easy</i>
3
+
4
+ - PyEmailerAJM uses pywin32 to automate the sending/reading of Outlook emails.
5
+
6
+ **Import**
7
+
8
+ - import PyEmailer class using `from PyEmailerAJM.PyEmailerAJM import PyEmailer`
9
+
10
+ **Notes**
11
+
12
+ - see [OutlookPywin32Commands.xlsx](OutlookPywin32Commands.xlsx) for list of commands that can be used with a message object.
13
+
14
+ - Email signature **text** can now be added as of v1.4
15
+ - Assuming the signature *.txt file is found in `%APPDATA%/Microsoft/Signatures/`
@@ -2,10 +2,10 @@ from setuptools import setup
2
2
 
3
3
  setup(
4
4
  name='PyEmailerAJM',
5
- version='1.2',
5
+ version='1.4',
6
6
  packages=['PyEmailerAJM'],
7
7
  url='https://github.com/amcsparron2793-Water/PyEmailer',
8
- download_url='https://github.com/amcsparron2793-Water/PyEmailer/archive/refs/tags/1.2.tar.gz',
8
+ download_url='https://github.com/amcsparron2793-Water/PyEmailer/archive/refs/tags/1.4.tar.gz',
9
9
  keywords=["Outlook", "Email", "Automation"],
10
10
  install_requires=['pywin32'],
11
11
  license='MIT License',
@@ -1,8 +0,0 @@
1
- # <u>PyEmailerAJM</u>
2
- ### <i>Makes automating Outlook emails quick and easy</i>
3
-
4
- - PyEmailerAJM uses pywin32 to automate the sending of Outlook emails.
5
-
6
- <b>Import</b>
7
-
8
- import PyEmailer class using `from PyEmailerAJM.PyEmailerAJM import PyEmailer`
File without changes
File without changes