Reputation: 633
I have developed the code which allows me to send an email with predefined text, which I set to change only where the date is Date -1
I need to add another functionality: If the current day is vbMonday
insert "weekend" instead of Date - 1
I was thinking about something along the lines of: If Date = vbMonday then instead of Date - 1 enter "weekend"
This is the part:
Sub Email_Outlook()
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "Hi," & vbNewLine & vbNewLine & _
"No events: " & Date - 1 & vbNewLine & vbNewLine & _
"Thanks" & vbNewLine & vbNewLine & _
"Thomas"
Thanks
Upvotes: 1
Views: 67
Reputation: 13386
strbody = "Hi," & vbNewLine & vbNewLine & _
"No events: " & IIf(Weekday(Date) = vbMonday, "weekend", Date - 1) & vbNewLine & vbNewLine & _
"Thanks" & vbNewLine & vbNewLine & _
"Thomas"
Upvotes: 3
Reputation: 43593
Try like this with the weekdays:
Public Sub TestMe()
If Weekday(Date) = vbWednesday Then
Debug.Print "It is Wednesday!"
End If
End Sub
Upvotes: 1