Перейти до основного матеріалу

Як змінити час за замовчуванням для затримки доставки в Outlook?

Якщо ввімкнути опцію затримки доставки ( Не доставляйте раніше на наступному знімку екрана) для електронного листа в Outlook час надсилання встановлено на 5:00 за замовчуванням. Припустимо, ви працюєте пізно ввечері і не хочете, щоб інші знали, що ви працюєте понаднормово. Перш ніж надсилати електронні листи, потрібно ввімкнути параметр затримки доставки. Після ввімкнення параметра вам потрібно змінити час надсилання за замовчуванням вручну. В іншому випадку електронний лист буде надіслано після 5:00 наступного дня. Чи є спосіб змінити цей час доставки за замовчуванням?

У цьому посібнику наведено код VBA, який допоможе вам змінити час за замовчуванням для параметра затримки доставки в Outlook.


Змініть час за замовчуванням для затримки доставки в Outlook за допомогою коду VBA

Ви можете застосувати наступний код VBA, щоб змінити час за замовчуванням для параметра затримки доставки в Outlook.

У наступному коді VBA:

Ви можете вказати два рази: затримка терміну доставки і Час увімкнення параметра затримки доставки.

Наприклад, ви встановлюєте час затримки доставки на 07:30, а параметр затримки доставки вмикається автоматично після 5:30. Коли ви надсилаєте електронний лист з 07:30 до 5:30, електронний лист буде надіслано безпосередньо. Якщо електронний лист надіслано з 5:30 до 07:30, його буде надіслано після 07:30 наступного дня.

Перевірте сценарій наступним чином.

1. Запустіть Outlook, натисніть інший + F11 клавіші одночасно, щоб відкрити Microsoft Visual Basic для додатків вікна.

2 В Microsoft Visual Basic для додатків вікно, двічі клацніть на Project1 > Об'єкти Microsoft Outlook > ThisOutlookSession відкрити ThisOutlookSession (Код) вікно, а потім скопіюйте наступний код у це вікно коду.

Код VBA: змініть час за замовчуванням для затримки доставки в Outlook

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
'Updated by Extendoffice & EWP 20230602
  Const xDelayTime As String = "07:30:00"  'The delay delivery time of emails
  Const xCompareTime As String = "17:30:00" 'The time to enable the delay delivery option
  Dim xMail As Outlook.MailItem
  Dim xWeekday As Integer
  Dim xNowTime As String
  Dim xIsDelay As Boolean
  Dim xRet1 As Integer
  Dim xRet2 As Integer
  On Error GoTo xError
  If (Item.Class <> olMail) Then Exit Sub
  Set xMail = Item
  xWeekday = Weekday(Date, vbMonday)
  xNowTime = Format(Now, "hh:nn:ss")
  xIsDelay = False
  xRet1 = StrComp(xNowTime, xDelayTime)
  xRet2 = StrComp(xNowTime, xCompareTime)
  If xRet1 = xRet2 Then
    xIsDelay = True
  End If
  If (xRet1 = -1) And (xRet2 = -1) Then
    xMail.DeferredDeliveryTime = Date & " " & xDelayTime
  Else
    If ((xWeekday = 5) And xIsDelay) Or (xWeekday = 6) Or (xWeekday = 7) Then
      xMail.DeferredDeliveryTime = (Date + (5 - xWeekday + 3)) & " " & xDelayTime
    ElseIf xIsDelay Then
      xMail.DeferredDeliveryTime = (Date + 1) & " " & xDelayTime
    End If
  End If
Exit Sub
xError:
  MsgBox "ItemSend: " & Err.Description, , "Kutools for Outlook"
End Sub

Примітки:

1) Ви можете змінити час затримки та час, щоб увімкнути опцію затримки доставки в наступних рядках.
Const xDelayTime як рядок = "07:30:00"
Const xCompareTime як рядок = "17:30:00"
2) Під час надсилання електронного листа у вихідні дні його буде надіслано після 07:30 у понеділок.

3. Збережіть код і натисніть клавішу інший + Q клавіші, щоб закрити Microsoft Visual Basic для додатків вікна.

Відтепер, коли ви надсилаєте електронний лист з 07:30 до 5:30, електронний лист надсилатиметься безпосередньо. Якщо електронний лист надіслано з 5:30 до 07:30, його буде надіслано після 07:30 наступного робочого дня.


Статті по темі

Змінити час нагадування за умовчанням про події протягом дня в Outlook
Зазвичай за замовчуванням час нагадування про подію протягом усього дня становить 18 годин у програмі Outlook 2007/2010 та 0.5 доби у програмі Outlook 2013. Іноді час нагадування за замовчуванням про подію протягом усього дня може не узгоджуватися з вашим графіком роботи. Тут ми представимо спосіб змінити час нагадування за замовчуванням про цілоденні події в Microsoft Outlook.

Змініть час виконання за замовчуванням в Outlook
Як ми знаємо, коли ми додаємо нагадування про подальший електронний лист у програмі Outlook, час за замовчуванням - 4:30 (або інший час залежно від робочого часу). Однак, можливо, ви захочете змінити час подальшого спостереження за замовчуванням, і нехай він нагадує вам на початку робочого часу, наприклад 9:00. У цій статті я покажу вам, як змінити час спостереження за замовчуванням у програмі Outlook.

Змініть розташування архіву за замовчуванням в Outlook
За замовчуванням Outlook має стандартне розташування для архівних файлів. Окрім розташування за замовчуванням, ви можете встановити власне розташування архіву для своїх архівних файлів. У цьому посібнику ми детально покажемо, як змінити розташування архіву за замовчуванням у програмі Outlook.

Змінити місце збереження вкладень за замовчуванням в Outlook
Вам набридло знаходити розташування вкладень, яке ви вказували кожного разу під час запуску Outlook? У цьому підручнику ми покажемо вам, як змінити місце вкладення за замовчуванням. Після цього вказана папка збереження вкладень буде відкриватися автоматично кожного разу, коли ви зберігаєте вкладення, навіть якщо перезапускаєте Outlook.

Змініть значення за умовчанням для події на весь день на «Зайнятий» у Outlook
За замовчуванням Outlook встановлює статус зустрічей і нарад на «Зайнятий», а подій на весь день — на «Безкоштовні» (див. знімок екрана нижче). Вам потрібно вручну змінювати статус «Показати як» на «Зайнятий» щоразу, коли ви створюєте подію на весь день. Щоб змінити відображення за замовчуванням як статус подій на весь день на «Зайнятий», у статті надано два способи.


Найкращі інструменти продуктивності офісу

Kutools для Outlook - Понад 100 потужних функцій, які покращать ваш Outlook

🤖 AI Mail Assistant: Миттєві професійні електронні листи з магією штучного інтелекту – геніальні відповіді одним клацанням, ідеальний тон, багатомовна майстерність. Трансформуйте електронну пошту без зусиль! ...

???? Автоматизація електронної пошти: Поза офісом (доступно для POP та IMAP)  /  Розклад надсилання електронних листів  /  Автоматична копія/прихована копія за правилами під час надсилання електронної пошти  /  Автоматичне пересилання (розширені правила)   /  Автоматично додавати привітання   /  Автоматично розділяйте електронні листи кількох одержувачів на окремі повідомлення ...

📨 Управління електронною поштою: Легко відкликайте електронні листи  /  Блокуйте шахрайські електронні листи за темами та іншими  /  Видалити повторювані електронні листи  /  розширений пошук  /  Консолідація папок ...

📁 Вкладення ProПакетне збереження  /  Пакетне від'єднання  /  Пакетний компрес  /  Автозавантаження   /  Автоматичне від'єднання  /  Автокомпресія ...

???? Магія інтерфейсу: 😊Більше красивих і класних смайликів   /  Підвищте продуктивність Outlook за допомогою вкладок  /  Згорніть Outlook замість того, щоб закривати ...

👍 Дива в один клік: Відповісти всім із вхідними вкладеннями  /   Антифішингові електронні листи  /  🕘Показувати часовий пояс відправника ...

👩🏼‍🤝‍👩🏻 Контакти та календар: Пакетне додавання контактів із вибраних електронних листів  /  Розділіть групу контактів на окремі групи  /  Видаліть нагадування про день народження ...

більше Особливості 100 Чекайте на ваше дослідження! Натисніть тут, щоб дізнатися більше.

 

 

Comments (42)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hi,
Would there be a way to change only the default delay time and NOT the time to enable the delay delivery option?
This comment was minimized by the moderator on the site
Hi

So useful! Can you add the option that if you are sending to people from within your organisation, this rule does not apply and emails are sent immediately?
This comment was minimized by the moderator on the site
Hi Crystal

This was just what I was looking for, it worked once, and I was very excited! Since then no matter what time of day, the emails send as soon as I click "Send". Any thoughts on what I've done wrong? I'd also love to be able to exclude 'high importance' flags.
This comment was minimized by the moderator on the site
Please ignore that request, seems it was to do with trust settings. Sorted now, thanks for the code!
This comment was minimized by the moderator on the site
I found that when you send an email on Sunday it is push to a week out as xMail.DeferredDeliveryTime = (Date + (vbSaturday - xWeekday + 2)) & " " & xDelayTime ends up with 8 days in the future instead of the expected one. As 7 (vbSaturday) - 1 (xWeekday on Sunday) + 2 is 8. This is my fix:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
'Updated by EWP 20230518
  Const xDelayTime As String = "07:30:00"  'The delay delivery time of emails
  Const xCompareTime As String = "17:30:00" 'The time to enable the delay delivery option
  Dim xMail As Outlook.MailItem
  Dim xWeekday As Integer
  Dim xNowTime As String
  Dim xIsDelay As Boolean
  Dim xRet1 As Integer
  Dim xRet2 As Integer
  On Error GoTo xError
  If (Item.Class <> olMail) Then Exit Sub
  Set xMail = Item
  xWeekday = Weekday(Date, vbMonday)
  xNowTime = Format(Now, "hh:nn:ss")
  xIsDelay = False
  xRet1 = StrComp(xNowTime, xDelayTime)
  xRet2 = StrComp(xNowTime, xCompareTime)
  If xRet1 = xRet2 Then
    xIsDelay = True
  End If
  If (xRet1 = -1) And (xRet2 = -1) Then
    xMail.DeferredDeliveryTime = Date & " " & xDelayTime
  Else
    If ((xWeekday = 5) And xIsDelay) Or (xWeekday = 6) Or (xWeekday = 7) Then
      xMail.DeferredDeliveryTime = (Date + (5 - xWeekday + 3)) & " " & xDelayTime
    ElseIf xIsDelay Then
      xMail.DeferredDeliveryTime = (Date + 1) & " " & xDelayTime
    End If
  End If
Exit Sub
xError:
  MsgBox "ItemSend: " & Err.Description, , "Kutools for Outlook"
End Sub
This comment was minimized by the moderator on the site
Hi Ehrin Pitts,

Thank you for the correction. I will check the code in the post and correct it.
This comment was minimized by the moderator on the site
This is a most useful piece of code, because it prevents me from disturbing people outside office hours.
However, I sometimes need to send an email outside normal hours and it is a nuisance to comment out the VBA code each time.
My suggestion is that if the "Importance" flage is set to high, then the mail will be sent immediately and not be delayed. Would it be possible for you to add such an exclusion in the code. (Still keeping the existing code, including the line with the xSenderAddress).
This comment was minimized by the moderator on the site
Hi Bernard,

The following VBA code helps to exclude the emails with a high importance flag. Please give it a try.
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
'Updated by Extendoffice 20230410
  Const xDelayTime As String = "07:30:00"  'The delay delivery time of emails
  Const xCompareTime As String = "17:30:00" 'The time to enable the delay delivery option
  Dim xMail As Outlook.MailItem
  Dim xWeekday As Integer
  Dim xNowTime As String
  Dim xIsDelay As Boolean
  Dim xRet1 As Integer
  Dim xRet2 As Integer
  On Error GoTo xError
  If (Item.Class <> olMail) Then Exit Sub
  Set xMail = Item
  If xMail.Importance = olImportanceHigh Then Exit Sub 'Exclude emails with a high importance flag
  xWeekday = Weekday(Date, vbSunday)
  xNowTime = Format(Now, "hh:nn:ss")
  xIsDelay = False
  xRet1 = StrComp(xNowTime, xDelayTime)
  xRet2 = StrComp(xNowTime, xCompareTime)
  If xRet1 = xRet2 Then
    xIsDelay = True
  End If
  If (xRet1 = -1) And (xRet2 = -1) Then
    xMail.DeferredDeliveryTime = Date & " " & xDelayTime
  Else
    If ((xWeekday = vbFriday) And xIsDelay) Or (xWeekday = vbSaturday) Or (xWeekday = vbSunday) Then
      xMail.DeferredDeliveryTime = (Date + (vbSaturday - xWeekday + 2)) & " " & xDelayTime
    ElseIf xIsDelay Then
      xMail.DeferredDeliveryTime = (Date + 1) & " " & xDelayTime
    End If
  End If
Exit Sub
xError:
  MsgBox "ItemSend: " & Err.Description, , "Kutools for Outlook"
End Sub
This comment was minimized by the moderator on the site
Thanks for this macro. I often work late in the evenings or early in the mornings but don't want emails to be sent to my colleagues outside of normal working hours (for me, 08:00 to 17:45, which I've modified in the macro myself).

Is there a way to add an additional clause to the macro for sending emails, please? Currently, if I work early in the morning on a weekday (say 06:00, before the working day officially starts at 08:00) then the macro will delay sending until 08:00 on the following working day. I would rather the email was sent at 08:00 on the current working day. I tested your macro on a Thursday morning at 07:54 and the sending has been delayed until 08:00 on Friday, whereas I would want it to be sent on Thursday at 08:00.

Emails sent after the end of the working day should be sent at the start of the next working day, as you have written. Any emails sent at any time on Saturday or Sunday should be sent at the start of the next working day, again as you have written.

It's been a while since I've written anything substantial in VBA so I'm turning my head inside out trying to find the solution, with no success.
This comment was minimized by the moderator on the site
Hi Dom,

I am sorry to reply to you so late. The following VBA code can help. Please give it a try.
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
'Updated by Extendoffice 20230410
  Const xDelayTime As String = "08:00:00"  'The delay delivery time of emails
  Const xCompareTime As String = "17:45:00" 'The time to enable the delay delivery option
  Dim xMail As Outlook.MailItem
  Dim xWeekday As Integer
  Dim xNowTime As String
  Dim xIsDelay As Boolean
  Dim xRet1 As Integer
  Dim xRet2 As Integer
  Dim xDelayInterval As Integer
  On Error GoTo xError
  If (Item.Class <> olMail) Then Exit Sub
  Set xMail = Item
  xWeekday = Weekday(Date, vbSunday)
  xNowTime = Format(Now, "hh:nn:ss")
  xIsDelay = False
  xRet1 = StrComp(xNowTime, xDelayTime)
  xRet2 = StrComp(xNowTime, xCompareTime)
  If xRet1 = xRet2 Then
    xIsDelay = True
  End If
  If (xRet1 = -1) And (xRet2 = -1) Then
    xMail.DeferredDeliveryTime = Date & " " & xDelayTime
  Else
    If ((xWeekday = vbFriday) And xIsDelay) Or (xWeekday = vbSaturday) Or (xWeekday = vbSunday) Then
      xMail.DeferredDeliveryTime = (Date + (vbSaturday - xWeekday + 2)) & " " & xDelayTime
    ElseIf xIsDelay Then
      xMail.DeferredDeliveryTime = (Date + 1) & " " & xDelayTime
    End If
  End If
Exit Sub
xError:
  MsgBox "ItemSend: " & Err.Description, , "Kutools for Outlook"
End Sub
This comment was minimized by the moderator on the site
Hi Crystal, the issue returned. No matter what time of day, the emails send as soon as I click "Send". Please let me know any advice. Thank you
This comment was minimized by the moderator on the site
Hi Angela,

The problem was reproduced in my case and we have updated the code. Please give it a try. Thank you for your comment.
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
'Updated by Extendoffice 20230117
  Const xDelayTime As String = "07:30:00"  'The delay delivery time of emails
  Const xCompareTime As String = "17:30:00" 'The time to enable the delay delivery option
  
  Dim xMail As Outlook.MailItem
  Dim xWeekday As Integer
  Dim xNowTime As String
  Dim xIsDelay As Boolean
  On Error GoTo xError
  If (Item.Class <> olMail) Then Exit Sub
  Set xMail = Item
  xWeekday = Weekday(Date, vbSunday)
  xNowTime = Format(Now, "hh:nn:ss")
  xIsDelay = False
  If StrComp(xNowTime, xDelayTime) = StrComp(xNowTime, xCompareTime) Then
    xIsDelay = True
  End If
  If ((xWeekday = vbFriday) And xIsDelay) Or (xWeekday = vbSaturday) Or (xWeekday = vbSunday) Then
    xMail.DeferredDeliveryTime = (Date + (vbSaturday - xWeekday + 2)) & " " & xDelayTime
  ElseIf xIsDelay Then
    xMail.DeferredDeliveryTime = (Date + 1) & " " & xDelayTime
  End If
Exit Sub
xError:
  MsgBox "ItemSend: " & Err.Description, , "Kutools for Outlook"
End Sub
This comment was minimized by the moderator on the site
Hi Crystal,
I fixed the issue by closing the Outlook application and re-opening it after saving the VBA code. Thank you for this!
This comment was minimized by the moderator on the site
Hi Crystal, I followed your instructions and enabled macros, but the emails are still sending as soon as I click "Send".

I have Outlook version 2101 (Build 13628.20274).

1. I did not modify any variables in the code, so it is saved just as you have instructed for "ThisOutlookSession".
2. It is the only code in "ThisOutlookSession".
3. The current time is 3:19 AM Eastern Time, so I would expect the emails to be delayed upon clicking "Send" since I am attempting to send an email during the time period of 5:30 PM - 07:30 AM.
4. I verified the Macros are enabled.

Is there anything else you can suggest that could cause this macro not to work? Thank you

From the tutorial: "From now on, when you send an email during 07:30 AM - 5:30 PM, the email will be sent directly. If an email is sent during 5:30 PM – 07:30 AM, it will be scheduled to send after 07:30 AM the next workday."
This comment was minimized by the moderator on the site
Hi Crystal, I followed your instructions and enabled macros, but the emails are still sending as soon as I click "Send". I have Outlook version 2101 (Build 13628.20274).
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations