2
我有一個MS Access數據庫,我想在其中調用一個函數,該函數的字符串中包含今天的日期,如下所示。我正在嘗試將今天的日期放在將要創建的新電子郵件的主題行和電子郵件正文中。任何想法來實現這一目標?如何在VBA中的字符串中調用函數
Private Sub Command_Click()
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
Dim ThisDay As Date
ThisDay = Format(Now, "mm/dd/yy")
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
With objEmail
.To = ""
.CC = ""
.Subject = "Daily Email Processed " *(Thisday)
.Body = "Hi," + vbNewLine + vbNewLine + vbNewLine + "Please find below the number of Emails processed for the " + vbNewLine + vbNewLine + "Email Count = " + vbNewLine + "O Count = "
.Attachments.Add ""
.Attachments.Add ""
.Display
End With
Set objOutlook = Nothing
End Sub
'Format()'返回一個字符串,所以Dim Dim ThisDay As String'。該代碼是否存在其他問題?你有錯誤嗎? – HansUp 2013-02-12 05:55:56
好的謝謝你,但我將如何在.Subject =「每日電子郵件計數」&Thisday&像這樣或什麼? – CrashOverride 2013-02-12 06:01:49
通常情況下,編寫帶有主題,正文,配方等的'mailto:// ..'url並讓操作系統在發送之前解析郵件客戶端以編輯郵件。請參閱http://email.about.com/od/mailtoemaillinks/a/mailto_elements.htm,並確保您在添加到網址之前對所有數據進行UrlEncode。 – ja72 2013-02-12 06:12:46