Note: If you need to send out a massive amount of emails this code is not for you, instead we recommend FMS's Total Access Emailer.
Note 2: You must add a reference to Outlook in your Access project in order for this code to work, if you need an alternate version that does not require it then look at the next section of this post below:
Dim objOutlook As Outlook.Application
Dim objOutLookMsg As Outlook.MailItem
Dim strBody as String
strBody = "Insert you body message here."
Set objOutlook = New Outlook.Application
Set objOutLookMsg = objOutlook.CreateItem(0)
With objOutLookMsg
.To = "w@what_Ever.com"
.CC = "any@what_ever.com"
.Subject = "Enter Your Subject Here"
.Body = strBody
.Send
End With
Code without a reference to Outlook:
Dim objOutlook As Object
Dim objOutLookMsg As Object
Dim strBody as String
strBody = "Insert you body message here."
Set objOutlook = CreateObject("Outlook.Application")
Set objOutLookMsg = objOutlook.CreateItem(0)
With objOutLookMsg
.To = "w@what_Ever.com"
.CC = "any@what_ever.com"
.Subject = "Enter Your Subject Here"
.Body = strBody
.Send
End With
ACCESS EXPERTS
Friday, November 6, 2009
Criteria for the current month in a query
The other day I needed to create a query where it returns all records with dates for the current month. I did not want to hard code the beginning and ending dates in the query, so I came up with the following line of code you can paste into your query:
Between CDate(Month(Date()) & "/1/" & Year(Date())) And DateAdd("m",1,CDate(Month(Date()) & "/1/" & Year(Date())))-1
The criteria line above uses the "Between And" operators to calculate the first of the month and the end of the month of the current date. Enjoy!
Between CDate(Month(Date()) & "/1/" & Year(Date())) And DateAdd("m",1,CDate(Month(Date()) & "/1/" & Year(Date())))-1
The criteria line above uses the "Between And" operators to calculate the first of the month and the end of the month of the current date. Enjoy!
Subscribe to:
Posts (Atom)