簡體   English   中英

從某個日期起每 14 天發送一次電子郵件提醒

[英]Sending email reminder every 14 days from a Date

下午好。 我在 Excel 文件中使用 VBA 代碼,如果文件在 14 天內未保存,我希望使用其他代碼行來發送定期電子郵件提醒。 以下是我使用的代碼。 我已經搜索過,但沒有找到額外的代碼來完成我所追求的。 預先感謝您的專業知識和幫助。 子 SEND_Colleague()

Dim MyFile As String
MyFile = ActiveWorkbook.Name
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:= & MyFile
Set OutlookApp = CreateObject("Outlook.Application")

Set OutlookMail = OutlookApp.CreateItem(0)
On Error Resume Next
On Error GoTo 0
With OutlookMail
    .to = "JaneDoe@mail.com"
    .Importance = 2
    .Subject = ActiveWorkbook.Name
    If InStr(Filename, ".") > 0 Then
        End If
    .HTMLbody = "<html><body><p><font size=4>My Colleague: <p></p>" _
    & "</p><p>Please navigate to the tracking log named in the subject line of this email by clicking the link below and update the <b><i>Product</i></b> section of the log. <p></p>" _
    & "Once your updates are entered, click the form control button in <b>Cell B61</b>. The workbook will be saved to the Network shared folder and closed automatically.  Thereafter, the Outlook mail program will be initiated and a pop-up warning message will appear.  Click <u><b>Allow</b></u> and an email will be sent to the area leader.  A copy of the email can be found in your Outlook <i>Sent</i> folder.<p>" _
    & "</p><p><b><FONT COLOR=red>Note, you must return to this log and follow the steps above every 14 days until all thrid-party claims are fully adjudicated. </p></b><FONT COLOR=black>" _
    & "</p><p>Thank You</p>" _
    
    .SEND
    End With
    Set OutlookMail = Nothing
    Set OutlookApp = Nothing
    ActiveWorkbook.Close
    End Sub

您想檢查上次編輯日期是否大於 14 天。

您可以使用ThisWorkbook.BuiltInDocumentProperties訪問工作簿的信息,這將返回文件屬性的集合。 最后修改的日期應該有索引 12。然后,存儲文件的最后修改日期的值:

Dim DateLastModified As Date
DateLastModified = ThisWorkbook.BuiltinDocumentProperties(12)

然后將該日期與今天的日期進行比較(如果您願意,還可以比較時間,因為ThisWorkbook.BuiltinDocumentProperties(12)還包含時間信息)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM