[英]Adding current quarter to email subject - Python
我正在嘗試編寫一個腳本,將當前季度添加到 email 的主題中,但我不確定是否可行,我們將不勝感激。
請看下面的代碼:
import win32com.client as client
import datetime
# Get Quarter
Today=datetime.datetime.now()
# Using Pandas Timestamp to get quarter
TodayTimeStamp=pd.Timestamp(Today)
quarter = TodayTimeStamp.quarter
quarter
# Send the email
outlook = client.Dispatch('Outlook.Application')
# Mail item
message = outlook.CreateItem(0)
message.Display()
message.To = "Louise.Sweeney.Contractor@pepsico.com"
message.Subject = "File Q"+quarter
message.HTMLBody = "Hello World"
message.Send()
我不確定您是否遇到任何錯誤,但是將此添加到您的主題應該沒有問題,您只需確保將四分之一轉換為字符串類型。 你可以像下面那樣做
message.Subject = f'File Q{quarter}'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.