Passer au contenu principal

Comment modifier le délai par défaut de livraison différée Outlook?

Lors de l'activation de l'option de livraison différée (le Ne pas livrer avant option dans la capture d'écran suivante) pour un e-mail dans Outlook, l'heure d'envoi est fixée par défaut à 5h00. Supposons que vous travailliez tard le soir et que vous ne vouliez pas que les autres sachent que vous faites des heures supplémentaires. Vous devez activer l’option de livraison différée de vos e-mails avant de les envoyer. Après avoir activé l'option, vous devez modifier manuellement l'heure d'envoi par défaut. Dans le cas contraire, l'e-mail sera envoyé après 5h00 le lendemain. Existe-t-il un moyen de modifier ce délai de livraison par défaut ?

Ce didacticiel fournit un code VBA pour vous aider à modifier l'heure par défaut de l'option de livraison différée dans Outlook.


Modifier le délai par défaut de retard de livraison dans Outlook avec du code VBA

Vous pouvez appliquer le code VBA suivant pour modifier l'heure par défaut de l'option de livraison différée dans Outlook.

Dans le code VBA suivant :

Vous pouvez spécifier deux temps : le retarder le délai de livraison les nouveautés délai d'activation de l'option de livraison différée.

Par exemple, vous définissez l'heure de livraison différée à 07h30 et définissez l'option de livraison différée pour qu'elle soit activée automatiquement après 5h30. Lorsque vous envoyez un e-mail entre 07h30 et 5h30, l'e-mail sera envoyé directement. Si un e-mail est envoyé entre 5h30 et 07h30, il sera programmé pour être envoyé après 07h30 le lendemain.

Veuillez tester le script comme suit.

1. Lancez votre Outlook, appuyez sur la autre + F11 touches simultanément pour ouvrir le Microsoft Visual Basic pour applications fenêtre.

2. dans le Microsoft Visual Basic pour applications fenêtre, double-cliquez sur Project1 > Microsoft Outlook Objets > CetOutlookSession ouvrir le CetOutlookSéance (Code) fenêtre, puis copiez le code suivant dans cette fenêtre de code.

Code VBA : modifier le délai de livraison par défaut dans 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

Notes:

1) Vous pouvez modifier le délai et le délai d'activation de l'option de livraison différée dans les lignes suivantes.
Const xDelayTime As String = "07:30:00"
Const xCompareTime As String = "17:30:00"
2) Lors de l'envoi d'un e-mail le week-end, il sera programmé pour être envoyé après 07h30 le lundi.

3. Enregistrez le code et appuyez sur le autre + Q touches pour fermer le Microsoft Visual Basic pour applications fenêtre.

Désormais, lorsque vous envoyez un e-mail entre 07h30 et 5h30, l'e-mail sera envoyé directement. Si un e-mail est envoyé entre 5h30 et 07h30, il sera programmé pour être envoyé après 07h30 le jour ouvrable suivant.


Articles connexes

Modifier l'heure de rappel par défaut des événements d'une journée dans Outlook
Normalement, l'heure de rappel par défaut d'un événement d'une journée entière est de 18 heures. Outlook 2007/2010 et 0.5 jour en Outlook 2013. Parfois, l'heure de rappel par défaut d'un événement d'une journée entière peut ne pas correspondre à votre horaire de travail. Nous présenterons ici la manière de modifier l'heure de rappel par défaut des événements d'une journée entière dans Microsoft. Outlook.

Modifier le temps de suivi par défaut dans Outlook
Comme nous le savons, lorsque nous ajoutons un rappel de suivi pour un e-mail dans Outlook, l'heure de suivi par défaut est 4h30 (ou une autre heure en fonction de vos horaires de travail). Cependant, vous souhaiterez peut-être modifier l'heure de suivi par défaut et la laisser vous rappeler au début des heures de travail, par exemple à 9h00. Dans cet article, je vais vous montrer comment modifier le temps de suivi par défaut dans Outlook.

Modifier l'emplacement d'archive par défaut dans Outlook
Par défaut, Outlook a un emplacement par défaut pour les fichiers d'archive. Outre l'emplacement par défaut, vous pouvez définir votre propre emplacement d'archive pour vos fichiers d'archives. Dans ce didacticiel, nous allons vous montrer comment modifier l'emplacement d'archive par défaut dans Outlook dans les détails.

Modifier l'emplacement d'enregistrement par défaut des pièces jointes dans Outlook
Vous en avez marre de retrouver à chaque lancement l'emplacement de pièce jointe que vous avez précisé Outlook? Dans ce didacticiel, nous allons vous montrer comment modifier l'emplacement par défaut des pièces jointes. Après cela, le dossier de sauvegarde des pièces jointes spécifié sera ouvert automatiquement chaque fois que vous enregistrerez les pièces jointes, même si vous redémarrez le Outlook.

Modifiez la valeur par défaut de l'événement d'une journée entière sur Occupé à Outlook
Par défaut, Outlook définit le statut des rendez-vous et des réunions sur « Occupé », mais les événements d'une journée entière sur « Libre » (voir capture d'écran ci-dessous). Vous devez modifier manuellement le statut Afficher en tant que sur Occupé chaque fois que vous créez un événement d'une journée entière. Pour modifier l'affichage par défaut du statut des événements d'une journée entière sur Occupé, l'article vous propose deux méthodes.


Meilleurs outils de productivité bureautique

Kutools for Outlook - Plus de 100 fonctionnalités puissantes pour booster votre Outlook

Email Automation: Réponse automatique (absent du bureau)  /  Planifier l'envoi emails  /  CC / BCC automatique  /  Avancé Transfert automatique  /  Ajout automatique 

Email Management: Rappel facile des e-mails  /  Bloquer les e-mails frauduleux  /  Supprimer les e-mails en double  /  🔎Recherche avancée  /  Consolider les dossiers 

(I.e. Pièces jointes ProSauvegarde par lots  /  Détachement par lots  /  Compression par lots  /  Enregistrement automatique   /  Détachement automatique  /  Compression automatique 

???? Magie de l’interface et de l’interaction: ????Plus d'émojis jolis et cool   /  Apporte les onglets du navigateur directement dans votre Outlook  /  Minimiser Outlook Au lieu de fermer 

???? Merveilles en un clic: Répondre à tous avec les pièces jointes entrantes  /   Anti-Phishing Emails   /  🕘Afficher le fuseau horaire de l'expéditeur  /  Envoyer aux destinataires séparément 

👩🏼‍🤝‍👩🏻 Contacts et calendrier: Ajouter par lots des contacts à partir des e-mails sélectionnés  /  Diviser un groupe de contacts en groupes individuels  /  Supprimer les rappels d'anniversaire 

infos Caractéristiques 100 Attendez votre exploration ! Cliquez ici pour en savoir plus.

 
Comments (38)
No ratings yet. Be the first to rate!
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).
This comment was minimized by the moderator on the site
This is awesome.

This is a longshot - but i have work and personal accounts in Outlook. Is there a way to set this only for certain accounts?
This comment was minimized by the moderator on the site
Hi Ann,
The following VBA script may help. Please give it a try.
In this line: xAccount = "Your email account", please replace the text "You email account" with your own account. For multiple accounts, please use a semicolon ";" to separate them.

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
  Dim xSenderAddress As String
  Dim xAccount As String
  On Error GoTo xError
  If (Item.Class <> olMail) Then Exit Sub
  Set xMail = Item
  xSenderAddress = ""
  xSenderAddress = xMail.SendUsingAccount.SmtpAddress
  xAccount = "Your email account"  'Specify your email account here and use ; to separate different accounts
  If VBA.InStr(xAccount, xSenderAddress) = 0 Then Exit Sub
  xWeekday = Weekday(Date, vbSunday)
  xNowTime = Format(Now, "hh:nn:ss")
  xIsDelay = False
  If StrComp(xNowTime, xDelayTime) = StrComp(xNowTime, xCompareTime) Then
    xIsDelay = True
  End If
  Debug.Print xIsDelay
  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
I ended up deleting my other code, and still cannot get this to work. No error comes up when I hit send. I commented out the code you bolded above
This comment was minimized by the moderator on the site
Hi Brian,

Please check if the enable macros options are enabled in your Outlook.
https://www.extendoffice.com/images/stories/comments/comment-picture-zxm/enable_macros.png
This comment was minimized by the moderator on the site
You are the goat! That was it :)
This comment was minimized by the moderator on the site
That's a pretty advanced Version of Outlook, Brian! 😄
This comment was minimized by the moderator on the site
Heyo, this isn't working for me. I am on outlook version 2210. I do have another function as well in ThisOutlookSession. Could you help me see what might be up?
This comment was minimized by the moderator on the site
Hi Brian,
If you already have a function in ThisOutlookSession that has the same name as this VBA code, the two functions will conflict.
If these two VBA codes have different names, you can remove the following line from the code and check if error is displayed when the Send button is clicked. Then tell me the error you got.
On Error GoTo xError
This comment was minimized by the moderator on the site
I have applied this and it works. However, how do I back out the VBA Code to not have this feature enabled?
This comment was minimized by the moderator on the site
Hi Travis,
If you just want to disable the code and still need it in the future, please comment the entire code in the VBA editor.
1. Open the VBA Editor (press the Alt + F11 keys).
2. Right click anywhere on the ribbon.
3. Select the “Edit” Toolbar to add the Edit toolbar to the ribbon.
https://www.extendoffice.com/images/stories/comments/comment-picture-zxm/vba1.png
4. Select the entire VBA code and click the Comment Block button.
Note: If you want to enable the code again, just select the entire code and click the Uncomment Block button.
https://www.extendoffice.com/images/stories/comments/comment-picture-zxm/vba2.png
This comment was minimized by the moderator on the site
I have used this and works great, however I need to remove and turn off the automatic delayed delivery checkbox. Can you please help?
This comment was minimized by the moderator on the site
I applied the VBA script and it worked great. How do I undo it? I'm trying to disable delayed send back to unchecked as default.
This comment was minimized by the moderator on the site
Can the general default delay time of 5:00 PM be changed to (say) 10:00 AM? I have a work situation that requires me to create a daily email early in the morning but not send until 10am - this is generally the only time I need to delay a send, so my default of 10:00 AM would save a bit of editing every morning.
This comment was minimized by the moderator on the site
Hi Michael,
The default delay time can be changed from 5:00 PM to 10:00 AM when you click the Send button, but it works for all emails you send early in the morning.
I need to confirm that if you only want to enable this delayed delivery for a specific email? If so, the code won't work for your needs.
This comment was minimized by the moderator on the site
I'd like the default Send time to be always 10:00AM, not 5:00PM. If I need to change the delivery time for another email, I'm happy to do that, but for my daily task, 10:00AM default is preferable.
This comment was minimized by the moderator on the site
Hi Michael.

google for SetDeliveryTime addin for Outlook (freeware).
This comment was minimized by the moderator on the site
GREAT!!! THANKS !
This comment was minimized by the moderator on the site
Perfect! That's exactly what I wanted - that addin changes the default "Do not deliver before" time from 5:00PM to whatever one wants to specify. Many thanks, Victor, and many thanks for your diligence following up my request, Crystal.
This comment was minimized by the moderator on the site
Hi Michael,
Because the Do not delivery before option is enabled when clicking the Send button with the VBA code, I need to confirm the following two issues. Those information need to be taken into account in the code. Sorry for the inconvenience.
1. Do you want to delay sending emails only in the early morning (before 10:00 am)? Is there a specific time range? Such as 7:00 - 9:59.
2. What if you send emails after 10:00? Are these emails sent directly without delay?
This comment was minimized by the moderator on the site
This is really useful

If you want to disable it just for one email (i.e. over-ride the default and have this one email send out of work hours) how would you do that?
I have tried going into 'Outbox' and taking off the delay delivery - but when I click send, it just goes back into the 'outbox' with the delay delivery turned back on.

Appreciate any advice!
This comment was minimized by the moderator on the site
Hi Liam,
Try the following VBA code.
If you need to turn off the delay delivery for one email, after sending it, go to the Outbox, double click the email to open it. Click Options > Delay Delivery > Uncheck the Do not deliver before checkbox > close the Properties dialog box > Click Send.
https://www.extendoffice.com/images/stories/comments/comment-picture-zxm/delay-delivery.png

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
'Updated by Extendoffice 20221124
  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
  If xMail.Submitted = True Then Exit Sub
  xWeekday = Weekday(Date, vbSunday)
  xNowTime = Format(Now, "hh:nn:ss")
  xIsDelay = (StrComp(xNowTime, xCompareTime) > 0)
  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
This is great thanks, what if you want a one time email on the weekend to send right away, how would you do that?
This comment was minimized by the moderator on the site
Hi Isabelle,
I don't quite understand what you mean. You mean delay all emails and send them on weekend together?
I need more information about your question. Sorry for the inconvenience.
This comment was minimized by the moderator on the site
This did not work for me
This comment was minimized by the moderator on the site
Hi David Koenig,
Did you get any error prompt? I need to know more specific about your issue, such as your Outlook version. Sorry for the inconvinience.
This comment was minimized by the moderator on the site
It is 01:19 (UTC+1) and I followed your steps but then when I tested from my pro e-mail address to my private one, I clicked on "New e-mail", wrote a test e-mail and clicked on sent and it sent the e-mail right away.
This comment was minimized by the moderator on the site
Hi Lounge,

The code has been updated, please give it a try. Thank you for your feedback.
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
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations