I need one macro on Outlook that do the logic below:
- Every workday between 9:00 am to 10:00am check in specific folder if have any email, from that day.
- If don't have email, send an simple mail to specific person.
Thank you very much.
I need one macro on Outlook that do the logic below:
Thank you very much.
Every workday between 9:00 am to 10:00am check in specific folder if have any email, from that day.
You need to run a timer to run the task periodically. See Outlook VBA - Run a code every half an hour for more information. Use the Find/FindNext or Restrict methods of the Items class to find Outlook items that correspond to your criteria.
If don't have email, send an simple mail to specific person.
If there is no item found see #1, you can create and submit the mail item.
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Nancy Davolio")
objOutlookRecip.Type = olTo
' Add the CC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Michael Suyama")
objOutlookRecip.Type = olCC
' Add the BCC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Andrew Fuller")
objOutlookRecip.Type = olBCC
' Set the Subject, Body, and Importance of the message.
.Subject = "This is an Automation test with Microsoft Outlook"
.Body = "This is the body of the message." &vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High importance
' Resolve each Recipient's name.
For Each ObjOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next
.Save
.Send
End With