UtilityLibAPI 1.2511.27__tar.gz → 1.2511.29__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.
Files changed (17) hide show
  1. {utilitylibapi-1.2511.27/src/UtilityLibAPI.egg-info → utilitylibapi-1.2511.29}/PKG-INFO +14 -1
  2. utilitylibapi-1.2511.29/README.md +30 -0
  3. {utilitylibapi-1.2511.27 → utilitylibapi-1.2511.29}/pyproject.toml +1 -1
  4. utilitylibapi-1.2511.27/src/UtilityLibAPI/7zArchiveLib.py → utilitylibapi-1.2511.29/src/UtilityLibAPI/Archive7zLib.py +2 -2
  5. {utilitylibapi-1.2511.27 → utilitylibapi-1.2511.29}/src/UtilityLibAPI/MailSenderLib.py +37 -23
  6. {utilitylibapi-1.2511.27 → utilitylibapi-1.2511.29}/src/UtilityLibAPI/__init__.py +3 -1
  7. {utilitylibapi-1.2511.27 → utilitylibapi-1.2511.29/src/UtilityLibAPI.egg-info}/PKG-INFO +14 -1
  8. {utilitylibapi-1.2511.27 → utilitylibapi-1.2511.29}/src/UtilityLibAPI.egg-info/SOURCES.txt +1 -1
  9. utilitylibapi-1.2511.27/README.md +0 -17
  10. {utilitylibapi-1.2511.27 → utilitylibapi-1.2511.29}/LICENSE +0 -0
  11. {utilitylibapi-1.2511.27 → utilitylibapi-1.2511.29}/setup.cfg +0 -0
  12. {utilitylibapi-1.2511.27 → utilitylibapi-1.2511.29}/src/UtilityLibAPI/EnDeCodeLib.py +0 -0
  13. {utilitylibapi-1.2511.27 → utilitylibapi-1.2511.29}/src/UtilityLibAPI/ExtWrapper7zLib.py +0 -0
  14. {utilitylibapi-1.2511.27 → utilitylibapi-1.2511.29}/src/UtilityLibAPI/SessionVARLib.py +0 -0
  15. {utilitylibapi-1.2511.27 → utilitylibapi-1.2511.29}/src/UtilityLibAPI.egg-info/dependency_links.txt +0 -0
  16. {utilitylibapi-1.2511.27 → utilitylibapi-1.2511.29}/src/UtilityLibAPI.egg-info/requires.txt +0 -0
  17. {utilitylibapi-1.2511.27 → utilitylibapi-1.2511.29}/src/UtilityLibAPI.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: UtilityLibAPI
3
- Version: 1.2511.27
3
+ Version: 1.2511.29
4
4
  Summary: UtilityLibAPI Python package
5
5
  Author-email: James Lin <tylin123@ms27.hinet.net>
6
6
  License: Copyright (c) 2025 James Lin **UtilityLibAPI**
@@ -33,6 +33,19 @@ Dynamic: license-file
33
33
  #UtilityLibAPI Classes
34
34
 
35
35
  ## History of version
36
+ Version 1.2511.29: 2025/11/29<BR>
37
+ Fixed MailSenderLib: Attachement file name encode problem.
38
+ Add function for user can modify mail caption of from field.
39
+
40
+ Version 1.2511.282: 2025/11/27<BR>
41
+ Fixed MailSenderLib: Attachement file name encode problem.
42
+
43
+ Version 1.2511.281: 2025/11/27<BR>
44
+ Modified 7zArchiveLib to Archive7zLib --> 7z Archive tools library
45
+
46
+ Version 1.2511.28: 2025/11/27<BR>
47
+ Fixed 7zArchiveLib --> 7z Archive tools library
48
+
36
49
  Version 1.2511.27: 2025/11/27<BR>
37
50
  Add 7zArchiveLib --> 7z Archive tools library
38
51
 
@@ -0,0 +1,30 @@
1
+ #UtilityLibAPI Classes
2
+
3
+ ## History of version
4
+ Version 1.2511.29: 2025/11/29<BR>
5
+ Fixed MailSenderLib: Attachement file name encode problem.
6
+ Add function for user can modify mail caption of from field.
7
+
8
+ Version 1.2511.282: 2025/11/27<BR>
9
+ Fixed MailSenderLib: Attachement file name encode problem.
10
+
11
+ Version 1.2511.281: 2025/11/27<BR>
12
+ Modified 7zArchiveLib to Archive7zLib --> 7z Archive tools library
13
+
14
+ Version 1.2511.28: 2025/11/27<BR>
15
+ Fixed 7zArchiveLib --> 7z Archive tools library
16
+
17
+ Version 1.2511.27: 2025/11/27<BR>
18
+ Add 7zArchiveLib --> 7z Archive tools library
19
+
20
+ Version 1.2510.22: 2025/10/21<BR>
21
+ Add ExtWrapper7zLib --> 7z Archive tools library
22
+
23
+ Version 1.2510.22: 2025/10/21<BR>
24
+ Add MailSenderLib --> CLASS_MailSender library
25
+
26
+ Version 0.1.1: 2025/10/13<BR>
27
+ Fixed export class path<BR>
28
+
29
+ Version 0.1.0: 2025/10/13<BR>
30
+ Create UtilityLibAPI -- EnDeCodeLib + SessionVARLib<BR>
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "UtilityLibAPI"
7
- version = "1.2511.27"
7
+ version = "1.2511.29"
8
8
  description = "UtilityLibAPI Python package"
9
9
  authors = [
10
10
  { name="James Lin", email="tylin123@ms27.hinet.net" }
@@ -5,7 +5,7 @@ import subprocess
5
5
  import re
6
6
  import glob
7
7
 
8
- class CLASS_7zArchive:
8
+ class CLASS_Archive7z:
9
9
  def __init__(self):
10
10
  self.on_progress = None
11
11
  self.seven_zip_path = self._find_7z_exe()
@@ -316,7 +316,7 @@ def GE_ProgressEvent(Pmf_Percent):
316
316
  if(__name__=="__main__"):
317
317
  ms_Path_7z: str;
318
318
 
319
- obj_7z = CLASS_7zArchive();
319
+ obj_7z = CLASS_Archive7z();
320
320
 
321
321
  obj_7z.CUF_SET_ProgressEvent(GE_ProgressEvent);
322
322
 
@@ -2,7 +2,10 @@ import smtplib
2
2
  from email.mime.text import MIMEText
3
3
  from email.mime.multipart import MIMEMultipart
4
4
  from email.mime.application import MIMEApplication
5
+ from email.mime.base import MIMEBase
5
6
  from email.utils import formataddr
7
+ from email.header import Header
8
+ from email import encoders
6
9
  from typing import List, Optional
7
10
  import os
8
11
  import mimetypes
@@ -23,10 +26,10 @@ class CLASS_MailSender:
23
26
  :param Pmb_UseSSL: 是否使用 SSL 連線 (預設 True)
24
27
  """
25
28
  self.Pms_SMTP_Server = Pms_SMTP_Server
26
- self.Pmi_Port = Pmi_Port
27
- self.Pms_Account = Pms_Account
28
- self.Pms_Password = Pms_Password
29
- self.Pmb_UseSSL = Pmb_UseSSL
29
+ self.Pmi_Port = Pmi_Port
30
+ self.Pms_Account = Pms_Account
31
+ self.Pms_Password = Pms_Password
32
+ self.Pmb_UseSSL = Pmb_UseSSL
30
33
 
31
34
  #------------------------------------------------------------
32
35
  def CUF_CreateMessage(self,
@@ -39,10 +42,14 @@ class CLASS_MailSender:
39
42
  Pobj_Bcc: Optional[List[str]] = None,
40
43
  Pobj_Attachments: Optional[List[str]] = None) -> MIMEMultipart:
41
44
  """
42
- 建立郵件內容(支援 HTML / 附件)
45
+ 建立郵件內容(支援 HTML / 附件 / 顯示別名)
43
46
  """
44
47
  msg = MIMEMultipart("alternative")
45
- msg["From"] = formataddr((Pms_From or self.Pms_Account, self.Pms_Account))
48
+
49
+ # 設定寄件者別名
50
+ from_addr = formataddr((Pms_From or self.Pms_Account, self.Pms_Account))
51
+ msg["From"] = from_addr
52
+
46
53
  msg["To"] = ", ".join(Pobj_To or [])
47
54
  if Pobj_Cc:
48
55
  msg["Cc"] = ", ".join(Pobj_Cc)
@@ -55,7 +62,7 @@ class CLASS_MailSender:
55
62
  if Pms_BodyHTML:
56
63
  msg.attach(MIMEText(Pms_BodyHTML, "html", "utf-8"))
57
64
 
58
- # 附件
65
+ # 附件(支援中文檔名 & Outlook)
59
66
  if Pobj_Attachments:
60
67
  for ms_path in Pobj_Attachments:
61
68
  try:
@@ -71,15 +78,20 @@ class CLASS_MailSender:
71
78
  with open(ms_path, "rb") as f:
72
79
  part = MIMEApplication(f.read(), _subtype=subtype)
73
80
  filename = os.path.basename(ms_path)
81
+ #part.add_header(
82
+ # "Content-Disposition",
83
+ # "attachment",
84
+ # filename=("utf-8", "", filename)
85
+ #)
86
+ filename_header = Header(filename, "utf-8").encode()
74
87
  part.add_header(
75
88
  "Content-Disposition",
76
- "attachment",
77
- filename=("utf-8", "", filename)
89
+ "attachement",
90
+ filename=filename_header
78
91
  )
79
92
  msg.attach(part)
80
93
  except Exception as e:
81
94
  print(f"⚠️ Can not add attachment: {ms_path} ({e})")
82
-
83
95
  return msg
84
96
 
85
97
  #------------------------------------------------------------
@@ -88,16 +100,18 @@ class CLASS_MailSender:
88
100
  Pms_BodyText: str,
89
101
  Pms_BodyHTML: Optional[str],
90
102
  Pobj_To: List[str],
103
+ Pms_From: Optional[str] = None,
91
104
  Pobj_Cc: Optional[List[str]] = None,
92
105
  Pobj_Bcc: Optional[List[str]] = None,
93
106
  Pobj_Attachments: Optional[List[str]] = None) -> bool:
94
107
  """
95
- 實際寄送郵件
108
+ 實際寄送郵件,支援寄件者別名
96
109
  """
97
110
  msg = self.CUF_CreateMessage(
98
111
  Pms_Subject=Pms_Subject,
99
112
  Pms_BodyText=Pms_BodyText,
100
113
  Pms_BodyHTML=Pms_BodyHTML,
114
+ Pms_From=Pms_From,
101
115
  Pobj_To=Pobj_To,
102
116
  Pobj_Cc=Pobj_Cc,
103
117
  Pobj_Bcc=Pobj_Bcc,
@@ -105,18 +119,19 @@ class CLASS_MailSender:
105
119
  )
106
120
 
107
121
  all_recipients = (Pobj_To or []) + (Pobj_Cc or []) + (Pobj_Bcc or [])
122
+ from_addr = formataddr((Pms_From or self.Pms_Account, self.Pms_Account))
108
123
 
109
124
  try:
110
125
  if self.Pmb_UseSSL:
111
126
  with smtplib.SMTP_SSL(self.Pms_SMTP_Server, self.Pmi_Port) as server:
112
127
  server.login(self.Pms_Account, self.Pms_Password)
113
- server.sendmail(self.Pms_Account, all_recipients, msg.as_string())
128
+ server.sendmail(from_addr, all_recipients, msg.as_string())
114
129
  else:
115
130
  with smtplib.SMTP(self.Pms_SMTP_Server, self.Pmi_Port) as server:
116
131
  server.ehlo()
117
132
  server.starttls()
118
133
  server.login(self.Pms_Account, self.Pms_Password)
119
- server.sendmail(self.Pms_Account, all_recipients, msg.as_string())
134
+ server.sendmail(from_addr, all_recipients, msg.as_string())
120
135
 
121
136
  print("✅ Send Success!")
122
137
  return True
@@ -124,7 +139,6 @@ class CLASS_MailSender:
124
139
  print("❌ Failure:", e)
125
140
  return False
126
141
 
127
-
128
142
  # ================================================================================
129
143
  # [範例]
130
144
  # 匯入剛才寫好的 CLASS_MailSender
@@ -132,20 +146,20 @@ class CLASS_MailSender:
132
146
  if __name__ == "__main__":
133
147
  # === 初始化郵件傳送物件 ===
134
148
  mailer = CLASS_MailSender(
135
- Pms_SMTP_Server="msr.xxxx.net",
149
+ Pms_SMTP_Server="msr.hinet.net",
136
150
  Pmi_Port=465,
137
- Pms_Account="xxx.biz@xx.hxxxt.net",
138
- Pms_Password="xxxxx*",
151
+ Pms_Account="gxxxx.xz@msa.hinet.net",
152
+ Pms_Password="xxxxx",
139
153
  Pmb_UseSSL=True
140
154
  )
141
155
 
142
156
  # === 郵件收件者設定 ===
143
- ml_To = ["gt504@gxxxxxh.biz", "txxxxx@ms27.xxxt.net"]
144
- ml_Cc = ["ebooxxx3@hotmail.com.tw"]
145
- ml_Bcc = ["xxxxsty.lin@xxx.hinet.net"] # 密件副本,不會顯示在郵件中
157
+ ml_To = ["xxxx4@xxxxxh.xxz", "xxxxxx23@xxx7.hxxxx.net"]
158
+ ml_Cc = ["exxxxx03@hotmail.com.tw"]
159
+ ml_Bcc = ["xxxxxxy.lin@msa.hxxxx.net"] # 密件副本,不會顯示在郵件中
146
160
 
147
161
  # === 郵件主題與內容 ===
148
- ms_Subject = "團隊週報通知"
162
+ ms_Subject = "團隊週報通知 wahaha 123*()F"
149
163
 
150
164
  ms_BodyText = """
151
165
  這是一封自動寄出的團隊週報通知。
@@ -171,8 +185,7 @@ if __name__ == "__main__":
171
185
 
172
186
  # === 附件路徑 ===
173
187
  ml_Attachments = [
174
- "X:\\TEMP\\BOOK\\RCR6000_匯出外部資料_RCR6000EXT_XXX.pdf",
175
- "X:\\TEMP\\BOOK\\K9AKW4.jpg"
188
+ "X:\\TEMP\\112年縣檸檬幼申報收入.jpg"
176
189
  ]
177
190
 
178
191
  # === 寄送 ===
@@ -180,6 +193,7 @@ if __name__ == "__main__":
180
193
  Pms_Subject=ms_Subject,
181
194
  Pms_BodyText=ms_BodyText,
182
195
  Pms_BodyHTML=ms_BodyHTML,
196
+ Pms_From = "太棒了!!abcdefg123",
183
197
  Pobj_To=ml_To,
184
198
  Pobj_Cc=ml_Cc,
185
199
  Pobj_Bcc=ml_Bcc,
@@ -2,9 +2,11 @@ from .EnDeCodeLib import CLASS_EnDeCodeLib
2
2
  from .SessionVARLib import CLASS_SessionVAR
3
3
  from .MailSenderLib import CLASS_MailSender
4
4
  from .ExtWrapper7zLib import CLASS_ExtWrapper7z
5
+ from .Archive7zLib import CLASS_Archive7z
5
6
 
6
7
  __all__ = ["CLASS_EnDeCodeLib",
7
8
  "CLASS_SessionVAR",
8
9
  "CLASS_MailSender",
9
- "CLASS_ExtWrapper7z"
10
+ "CLASS_ExtWrapper7z",
11
+ "CLASS_Archive7z"
10
12
  ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: UtilityLibAPI
3
- Version: 1.2511.27
3
+ Version: 1.2511.29
4
4
  Summary: UtilityLibAPI Python package
5
5
  Author-email: James Lin <tylin123@ms27.hinet.net>
6
6
  License: Copyright (c) 2025 James Lin **UtilityLibAPI**
@@ -33,6 +33,19 @@ Dynamic: license-file
33
33
  #UtilityLibAPI Classes
34
34
 
35
35
  ## History of version
36
+ Version 1.2511.29: 2025/11/29<BR>
37
+ Fixed MailSenderLib: Attachement file name encode problem.
38
+ Add function for user can modify mail caption of from field.
39
+
40
+ Version 1.2511.282: 2025/11/27<BR>
41
+ Fixed MailSenderLib: Attachement file name encode problem.
42
+
43
+ Version 1.2511.281: 2025/11/27<BR>
44
+ Modified 7zArchiveLib to Archive7zLib --> 7z Archive tools library
45
+
46
+ Version 1.2511.28: 2025/11/27<BR>
47
+ Fixed 7zArchiveLib --> 7z Archive tools library
48
+
36
49
  Version 1.2511.27: 2025/11/27<BR>
37
50
  Add 7zArchiveLib --> 7z Archive tools library
38
51
 
@@ -2,7 +2,7 @@ LICENSE
2
2
  README.md
3
3
  pyproject.toml
4
4
  setup.cfg
5
- src/UtilityLibAPI/7zArchiveLib.py
5
+ src/UtilityLibAPI/Archive7zLib.py
6
6
  src/UtilityLibAPI/EnDeCodeLib.py
7
7
  src/UtilityLibAPI/ExtWrapper7zLib.py
8
8
  src/UtilityLibAPI/MailSenderLib.py
@@ -1,17 +0,0 @@
1
- #UtilityLibAPI Classes
2
-
3
- ## History of version
4
- Version 1.2511.27: 2025/11/27<BR>
5
- Add 7zArchiveLib --> 7z Archive tools library
6
-
7
- Version 1.2510.22: 2025/10/21<BR>
8
- Add ExtWrapper7zLib --> 7z Archive tools library
9
-
10
- Version 1.2510.22: 2025/10/21<BR>
11
- Add MailSenderLib --> CLASS_MailSender library
12
-
13
- Version 0.1.1: 2025/10/13<BR>
14
- Fixed export class path<BR>
15
-
16
- Version 0.1.0: 2025/10/13<BR>
17
- Create UtilityLibAPI -- EnDeCodeLib + SessionVARLib<BR>