Ga naar hoofdinhoud

Hoe snel e-mail verzenden op basis van datum in Excel-cel?

Heeft u ooit geprobeerd een e-mail te verzenden op basis van de datum in de Excel-cel? Hier is bijvoorbeeld een lijst met datums in kolom A, en dan wil je een e-mail sturen met het onderwerp, de berichttekst naar een ontvanger (ook CC en BCC naar anderen), hoe kun je daarmee omgaan?

Stuur e-mail op basis van datum met VBA


Stuur e-mail op basis van datum met VBA

Om e-mail te verzenden op basis van de datum in Excel, kunt u alleen een macrocode toepassen.

1. Schakel het blad in met de gegevens en de datum die u gebruikt, en druk op Alt + F11 toetsen om het Microsoft Visual Basic voor toepassingen venster.

2. klikken Invoegen > Moduleen plak onderstaande code in het lege script. 

VBA: verzenden op datum

Sub email()
'UpdatebyExtendoffice20170831
    Dim xRg As Range
    Dim xRgEach As Range
    Dim xAddress As String
    Dim xEmail_Subject, xEmail_Send_From, xEmail_Send_To, xEmail_Cc, xEmail_Bcc, xEmail_Body As String
    Dim xMail_Object, xMail_Single As Object
    On Error Resume Next
    xAddress = ActiveWindow.RangeSelection.Address
    Set xRg = Application.InputBox("Select a range:", "KuTools For Excel", xAddress, , , , , 8)
    If xRg Is Nothing Then Exit Sub
    For Each xRgEach In xRg
        If xRgEach.Value = Date Then
            xEmail_Subject = Application.InputBox("Subject: ", "Kutools", , , , , , 2)
            xEmail_Send_From = Application.InputBox("Send from: ", "KuTools For Excel", , , , , , 2)
            xEmail_Send_To = Application.InputBox("Send to: ", "KuTools For Excel", , , , , , 2)
            If xEmail_Send_To = "" Then Exit Sub
            xEmail_Cc = Application.InputBox("CC: ", "KuTools For Excel", , , , , , 2)
            xEmail_Bcc = Application.InputBox("BCC: ", "KuTools For Excel", , , , , , 2)
            xEmail_Body = Application.InputBox("Message Body: ", "KuTools For Excel", , , , , , 2)
            Set xMail_Object = CreateObject("Outlook.Application")
            Set xMail_Single = xMail_Object.CreateItem(0)
            With xMail_Single
                .Subject = xEmail_Subject
                .To = xEmail_Send_To
                .cc = xEmail_Cc
                .BCC = xEmail_Bcc
                .Body = xEmail_Body
                .Send
            End With
        End If
    Next
End Sub

3. klikken lopen knop of druk op F5 toets om de code uit te voeren, verschijnt er een dialoogvenster om u eraan te herinneren een lijst met datums te selecteren. Zie screenshot:
doc verzonden op datum 1

4. Klik op OK en ga verder met het specificeren van het onderwerp van de e-mail, het e-mailadres van de afzender, het e-mailadres van de ontvanger, de CC, BCC en de berichttekst. Zie screenshot:

doc verzonden op datum 2 geschoten pijl naar rechts doc verzonden op datum 3 geschoten pijl naar rechts doc verzonden op datum 4
        doc pijl naar beneden
doc verzonden op datum 7 geschoten pijl naar links doc verzonden op datum 6 geschoten pijl naar links doc verzonden op datum 5

5. klikken OK > OK tot de laatste, en dan is de e-mail verzonden.
doc verzonden op datum 8

Opmerking: het e-mailadres van de afzender moet het standaardaccount in uw Outlook zijn.


Maak een mailinglijst en stuur e-mails

doc e-mail verzenden

Beste Office-productiviteitstools

馃 Kutools AI-assistent: Een revolutie teweegbrengen in de data-analyse op basis van: Intelligente uitvoering   |  Genereer code  |  Aangepaste formules maken  |  Analyseer gegevens en genereer grafieken  |  Roep Kutools-functies aan...
Populaire functies: Zoek, markeer of identificeer duplicaten   |  Verwijder lege rijen   |  Combineer kolommen of cellen zonder gegevens te verliezen   |   Ronde zonder formule ...
Super opzoeken: Meerdere criteria VLookup    VLookup met meerdere waarden  |   VOpzoeken over meerdere bladen   |   Fuzzy opzoeken ....
Geavanceerde vervolgkeuzelijst: Maak snel een vervolgkeuzelijst   |  Afhankelijke vervolgkeuzelijst   |  Multi-select vervolgkeuzelijst ....
Kolom Beheerder: Voeg een specifiek aantal kolommen toe  |  Kolommen verplaatsen  |  Schakel de zichtbaarheidsstatus van verborgen kolommen in  |  Vergelijk bereiken en kolommen ...
Uitgelichte functies: Raster focus   |  Ontwerpweergave   |   Grote formulebalk    Werkmap- en bladbeheer   |  resource Library (Auto-tekst)   |  Datumkiezer   |  Combineer werkbladen   |  Cellen coderen/decoderen    Stuur e-mails per lijst   |  Super filter   |   Speciaal filter (filter vet/cursief/doorhalen...) ...
Top 15 gereedschapsets12 Tekst Tools (toe te voegen tekst, Tekens verwijderen, ...)   |   50+ tabel Types (Gantt Chart, ...)   |   40+ Praktisch Formules (Bereken leeftijd op basis van verjaardag, ...)   |   19 Invoeging Tools (QR-code invoegen, Afbeelding invoegen vanaf pad, ...)   |   12 Camper ombouw Tools (Getallen naar woorden, Currency Conversion, ...)   |   7 Samenvoegen en splitsen Tools (Geavanceerd Combineer rijen, Gespleten cellen, ...)   |   ... en meer

Geef uw Excel-vaardigheden een boost met Kutools voor Excel en ervaar effici毛ntie als nooit tevoren. Kutools voor Excel biedt meer dan 300 geavanceerde functies om de productiviteit te verhogen en tijd te besparen.  Klik hier om de functie te krijgen die u het meest nodig heeft...

Omschrijving


Office-tabblad Brengt een interface met tabbladen naar Office en maakt uw werk veel gemakkelijker

  • Schakel bewerken en lezen met tabbladen in Word, Excel, PowerPoint in, Publisher, Access, Visio en Project.
  • Open en maak meerdere documenten in nieuwe tabbladen van hetzelfde venster in plaats van in nieuwe vensters.
  • Verhoogt uw productiviteit met 50% en vermindert honderden muisklikken voor u elke dag!
Comments (16)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
When I click run the date an I am asked to select a range nothing happens after I click ok?
This comment was minimized by the moderator on the site
Hi, jason, you need to select a cell or range that contains date(s), if the selected cell or range is empty or not contains date(s), the macro will exit.
This comment was minimized by the moderator on the site
Hi,


That is perfect, but when I add or change a date, it wont send the email Automatiklicht, I have to run the code again and by that I have to choose date range, sender, receiver and all info again. is there anyway to solve this issue?
This comment was minimized by the moderator on the site
its not going on next xRgEach if i am having same dates multiple times, its sending mails to same user multiple times.
This comment was minimized by the moderator on the site
Hi, vaibhav, you can remove the duplicate times by using Remove Duplicates feature in Data Tools under Data tab, then using the VBA.
This comment was minimized by the moderator on the site
脟ok te艧ekk眉r ederim..
This comment was minimized by the moderator on the site
Merhaba, bir excel dosyas谋nda hat谋rlat谋c谋 olarak bu konuyla ilgili VSB nin nas谋l yap谋ld谋臒谋 ile ilgili bilgiye ihtiyac谋m var. 脰rne臒in bo艧 bir h眉creye bilgi girildi臒inde bana mail at ya da 3 hafta s谋kl谋kla h眉creye bilgi girilip girilmedi臒iyle alakal谋 bana bilgi ver.

Hert眉rl眉 bilgi ve kayna臒a a莽谋臒谋m. 艦imdiden herkese te艧ekk眉r ederim..
This comment was minimized by the moderator on the site
Hi, Mehmet, here is a tutorial How To Send Email If A Certain Cell Is Modified In Excel? that talking about sending an email with the excel file as attachment if the cells in the specific range are modified, which may help you.
This comment was minimized by the moderator on the site
Bonjour j'ai copi茅 les codes, 脿 la validation il me demande bien les cellules concern茅es, mais lorsque que je valide, il ne me propose pas la suite des fen锚tres, sujets, adresses etc
This comment was minimized by the moderator on the site
Hi, boutry, sorry I that reply with English since I do not know French. May I know your date time format? I guess maybe the code only work for datetime in English date format.
This comment was minimized by the moderator on the site
The boxes do not automatically populate after I hit OK. Where do I change the subject, email address and body of the email in the code?
This comment was minimized by the moderator on the site
holagracias por tu ayuda...tengo una consulta.....en la formula Set xRgDate = Application.InputBox("Please select the due date column:", "KuTools For Excel", , , , , , 8), el 8 que significa?
This comment was minimized by the moderator on the site
Felicidades por el material; pero no me funciona. Al parecer el Rango no se llena, por ende queda vac铆o y sale de la rutina.

Alguna correcci贸n ?
This comment was minimized by the moderator on the site
This is close to what I need but I am stuck with two problems. 1st I need to run this across my entire workbook that gets new worksheets added daily. 2nd I need it to include the worksheet name in the email so I will know which sheet is due. I create new tickets (worksheets) with a field that is a future date, when that day arrives I need an email. Thank you for your help.
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