I have a MS Access database in which I want to call a function which has today's date in a string as below. I am trying to put today's date in the subject line and the email body on the new email which will be created. Any ideas to achieve this?
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()returns a string, soDim ThisDay As String. Do you have other issues with that code? Do you get an error?mailto://..url with subject, body, recipents etc, and let the OS resolve a mail client to edit the message before sending. See email.about.com/od/mailtoemaillinks/a/mailto_elements.htm, and make sure youUrlEncodeall data before adding to the url.