Trying to write a macro for Outlook 2003 that will check the current date/time and either send the current email immediately, or will delay it until the next business day at 8:30am. I'm a VB rookie, but have put together the following code (which isn't compiling correctly) to show where I'm at:
Any help you can give to assist would be greatly appreciated. Thanks in advance!Code:Public Sub CheckSendTime() Dim obj As Object Dim Mail As Outlook.MailItem Dim WkDay As String Dim SendHour As Integer Dim SendDay As Date Dim SendTime As Date SendDay = DateValue(Now) SendTime = TimeValue(Now) SendHour = Hour(Now) If SendHour < 8 Then SendHour = 8 - SendHour SendTime = SendTime.AddHours(SendHour) End If If SendHour > 18 Then SendHour = 32 - SendHour SendTime = SendTime.AddHours(SendHour) WkDay = Weekday(Today) If WkDay = 1 Then SendDay = SendDay.AddDays(1) End If If WkDay = 7 Then SendDay = SendDay.AddDays(2) End If Set obj = Application.ActiveInspector.CurrentItem If TypeOf obj Is Outlook.MailItem Then Set Mail = obj Mail.DefferedDeliveryTime = SendDay & SendTime Mail.Send End If End Sub
Mark




Reply With Quote