tags:

views:

64

answers:

4

How would I code a IF statement if I was trying to say

IF the date today is equal to Monday THEN

Have Outlook prepare 3 emails

ELSE

Have Outlook prepare 2 emails

END IF

I just need help setting up the "IF the date today is equal to Monday." How would that code look.


Set omail = CreateItem(olMailItem)

    With omail

    .Subject = "Daily Report"
    .BodyFormat = olFormatHTML
    .HTMLBody = "<a href ='" & fileL & "'>Daily Report</a>"
    .To = [email protected]
    .Display

How can I add a second link to this email?

+3  A: 
If Weekday(Now()) = vbMonday Then
    MsgBox "Monday"
End If
Thank you Dendarii!!!!!!!
Edmond
A: 

You can:

if (Weekday(Date, vbSunday) = vbMonday) then
   ...
else
   ...
end if
Alex K.
Thank You Alex K!!!!!
Edmond
A: 

VBA offers you a variety of date functions. You would need the Date function to get the actual date, and the Weekday function to get the weekday from a given date.

You condition would have to look like

If Weekday(Date) = vbMonday then
    ' create email
Else
End If
0xA3
Thank You OxA3!!!!
Edmond
+5  A: 

Rather than using an IF statement, I would use a SELECT CASE statement instead:

Select Case Weekday(Now())    
    Case vbMonday    
      'Create 3 emails

    Case vbTuesday    
      'Create 2 emails

    Case Else       
      'Do something else

End Select
Ardman
Thank you ardman!!!
Edmond