Computer >> 컴퓨터 >  >> 소프트웨어 >> Office

날짜를 기준으로 Excel에서 자동으로 이메일을 보내는 방법

이 기사에서는 이메일을 자동으로 보내는 가장 좋은 방법을 보여줍니다. Excel에서 날짜 기준 . 일반적으로 이메일 을 보내는 것은 쉽습니다. Outlook 에서 또는 Gmail , 그러나 이메일 을 보내고 싶을 때 특정 시간 또는 날짜에 , Microsoft Excel을 효과적으로 사용할 수 있습니다.

데이터 세트에는 몇 가지 이메일 주소 가 있습니다. (모두 admin@wsxdn.com을 제외한 더미 주소입니다. , 내 것입니다. 방법이 어떻게 작동하는지 보여드리기 위해 제 주소를 사용하고 있습니다.

날짜를 기준으로 Excel에서 자동으로 이메일을 보내는 방법

날짜를 기준으로 Excel에서 자동으로 이메일을 보내는 3가지 방법

1. Excel VBA를 사용하여 고정 날짜에 따라 자동으로 이메일 보내기

이메일을 자동으로 보낼 수 있습니다. Microsoft Visual Basic for Application 사용 (VBA ) 날짜 기준 . 날짜 목록을 만들 수 있습니다. 이메일 을 보내고 싶을 때 해당 수신자에게. 더 나은 이해를 위해 아래 과정을 살펴보겠습니다. 이 섹션에서는 날짜로만 작업합니다. .

단계:

  • 먼저 개발자 로 이동합니다.>> 비주얼 베이직 

날짜를 기준으로 Excel에서 자동으로 이메일을 보내는 방법

  • 그런 다음 VBA 창 열릴 것이다. 삽입 을 선택하십시오.>> 모듈
  • 날짜를 기준으로 Excel에서 자동으로 이메일을 보내는 방법VBA 모듈에 다음 코드를 입력합니다. .
Sub SendEmail01()
Dim Range_Select As Range
Dim Date_Range As Range
Dim Cell_Address As String
Dim Subject, Email_From, Email_To, Cc, Bcc, Email_Text As String
Dim Email_Obj, Single_Mail As Object
On Error Resume Next
Cell_Address = ActiveWindow.RangeSelection.Address
Set Range_Select = Application.InputBox("Select a range:", _
"Message Box", Cell_Address, , , , , 8)
If Range_Select Is Nothing Then Exit Sub
For Each Date_Range In Range_Select
If Date_Range.Value = Date Then
Subject = Application.InputBox("Subject: ", "Message", , , , , , 2)
Email_From = Application.InputBox("Send from: ", "Message Box", , , , , , 2)
Email_To = Application.InputBox("Send to: ", "Message Box", , , , , , 2)
If Email_To = "" Then Exit Sub
Cc = Application.InputBox("CC: ", "Message Box", , , , , , 2)
Bcc = Application.InputBox("BCC: ", "Message Box", , , , , , 2)
Email_Text = Application.InputBox("Message Body: ", "Message Box", , , , , , 2)
Set Email_Obj = CreateObject("Outlook.Application")
Set Single_Mail = Email_Obj.CreateItem(0)
With Single_Mail
.Subject = Subject
.To = Email_To
.Cc = Cc
.Bcc = Bcc
.Body = Email_Text
.send
End With
End If
Next
End Sub

날짜를 기준으로 Excel에서 자동으로 이메일을 보내는 방법

코드 설명

  • 먼저 몇 가지 필수 변수를 선언했습니다. Range_Select 날짜_범위 범위로; 셀_주소 , 제목 , 이메일_보낸사람 , Email_To , 참조 , 숨은 참조 , 이메일_문자 문자열로; Email_Obj 단일 메일 개체로 .
  • 그런 다음 Range_Select 를 설정합니다. InputBox 범위 를 선택할 수 있는 위치 메시지 상자를 통한 셀 수 .
  • 그 다음에는 을 사용합니다. VBA IF 문 제목도 설정 , 이메일_보낸사람 Email_To InputBox로 .
  • 이메일 주소 가 없는 경우 (Email_To=“” ), 하위 절차 종료 . 그렇지 않으면 새로운 IF 문에 더 많은 변수를 넣습니다. . 참조 숨은 참조 카본 카피 참조 및 블라인드 카본 카피 이메일 다른 사람들에게 보내고자 합니다.
  • 그런 다음 Outlook 응용 프로그램 개체 를 만듭니다. Email_Obj로 정의 . 또한 단일 메일 을 사용합니다. 만들다 항목 Email_Obj용 .
  • 그 다음에는 제목을 정의합니다. , Email_To , 참조 , 숨은 참조 , 이메일_문자 이메일 의 필수 부분으로 With 문으로 . 우리는 또한 .Send 명령문에서.

  • 이제 시트로 돌아가서 매크로 를 실행합니다. 이름이 SendEmail01 현재 매크로의 이름이므로 .

날짜를 기준으로 Excel에서 자동으로 이메일을 보내는 방법

  • 이 작업을 실행하면 메시지 상자 가 표시됩니다. 기간을 선택하라는 팝업 . 범위 선택 확인을 클릭합니다. .

날짜를 기준으로 Excel에서 자동으로 이메일을 보내는 방법

  • 그런 다음 다른 메시지 상자 팝업됩니다. 제목을 입력하고 확인을 클릭합니다. .

날짜를 기준으로 Excel에서 자동으로 이메일을 보내는 방법

  • 메시지 상자 체인이 표시됩니다. 이메일을 보내는 데 필요한 정보를 입력하라는 메시지 . 아래 이미지를 따르세요.
  • 이메일 주소 입력 .

날짜를 기준으로 Excel에서 자동으로 이메일을 보내는 방법

  • 이메일 주소 입력 이메일을 보낼 곳 .

날짜를 기준으로 Excel에서 자동으로 이메일을 보내는 방법

  • 참조 삽입 받는 사람의 주소 .

날짜를 기준으로 Excel에서 자동으로 이메일을 보내는 방법

  • 숨은 참조 메시지 상자 의 수신자 네가 원한다면. 저는 아무 것도 선택하지 않았습니다.

날짜를 기준으로 Excel에서 자동으로 이메일을 보내는 방법

  • 메시지를 입력하세요.

날짜를 기준으로 Excel에서 자동으로 이메일을 보내는 방법

  • 최종 메시지 상자 이후 , 경고 상자가 표시될 수 있습니다. Microsoft Outlook에서 . 허용을 클릭합니다. .

날짜를 기준으로 Excel에서 자동으로 이메일을 보내는 방법

이 작업은 이메일 을 보냅니다. 해당 메시지 상자에 입력한 주소로 .
기본 이메일입니다. .

날짜를 기준으로 Excel에서 자동으로 이메일을 보내는 방법

다음은 카본 카피 입니다. 이메일 .

날짜를 기준으로 Excel에서 자동으로 이메일을 보내는 방법

따라서 자동으로 보낼 수 있습니다. 이메일 Excel에서 날짜 기준 . 

자세히 알아보기:이메일을 자동으로 보내는 Excel 매크로(적합한 예 3개)

2. 다음 날짜를 기준으로 Excel에서 자동으로 이메일 보내기

이 섹션에서는 이메일을 보내드립니다 다음 또는 미래의 날짜 기준 . 누군가에게 이메일 을 보내고 싶다고 가정해 보겠습니다. prior to 3 days or 7 days. Let’s go through the following discussion on this matter.

단계:

  • First, go to Section 1 to see how to open a VBA Module .
  • Then type the following code in the VBA Module .
Public Sub SendEmail02()
Dim Date_Range As Range
Dim Mail_Recipient As Range
Dim Email_Text As Range
Dim Outlook_App_Create As Object
Dim Mail_Item As Object
Dim Last_Row As Long
Dim VB_CR_LF, Email_Body, Date_Range_Value, Send_Value, Subject As String
Dim i As Long
On Error Resume Next
Set Date_Range = Application.InputBox("Please choose the date range:", "Message Box", , , , , , 8)
If Date_Range Is Nothing Then Exit Sub
Set Mail_Recipient = Application.InputBox("Please select the Email addresses:", "Message Box", , , , , , 8)
If Mail_Recipient Is Nothing Then Exit Sub
Set Email_Text = Application.InputBox("Select the Email Text:", "Message Box", , , , , , 8)
If Email_Text Is Nothing Then Exit Sub
Last_Row = Date_Range.Rows.Count
Set Date_Range = Date_Range(1)
Set Mail_Recipient = Mail_Recipient(1)
Set Email_Text = Email_Text(1)
Set Outlook_App_Create = CreateObject("Outlook.Application")
For i = 1 To Last_Row
Date_Range_Value = ""
Date_Range_Value = Date_Range.Offset(i - 1).Value
If Date_Range_Value <> "" Then
If CDate(Date_Range_Value) - Date <= 7 And CDate(Date_Range_Value) - Date > 0 Then
Send_Value = Mail_Recipient.Offset(i - 1).Value
Subject = Email_Text.Offset(i - 1).Value & " on " & Date_Range_Value
VB_CR_LF = "<br><br>"
Email_Body = "<HTML><BODY>"
Email_Body = Email_Body & "Dear " & Send_Value & VB_CR_LF
Email_Body = Email_Body & "Text : " & Email_Text.Offset(i - 1).Value & VB_CR_LF
Email_Body = Email_Body & "</BODY></HTML>"
Set Mail_Item = Outlook_App_Create.CreateItem(0)
With Mail_Item
.Subject = Subject
.To = Send_Value
.HTMLBody = Email_Body
.Display
End With
Set Mail_Item = Nothing
End If
End If
Next
Set Outlook_App_Create = Nothing
End Sub

날짜를 기준으로 Excel에서 자동으로 이메일을 보내는 방법

Code Explanation

  • First, we declared some necessary variables:Date_Range , Mail_Recipient and Email_Text 범위로; Outlook_App_Create and Mail_Item 개체로; Last_Row and i as Long; VB_CR_LF (Visual Basic Carriage Return Line Feed ), Email_Body , Date_Range_Value , Send_Value , Subject as String .
  • Then we set Date_Range to an InputBox where it can select a range of dates via a Message Box . An If Statement is used to terminate Sub Procedure if the Date_Range is Nothing .
  • We also set Mail_Recipient and Email_Text to InputBox
  • After that, we create an Outlook Application Object which we define by Outlook_App_Create .
  • A date interval is introduced. In this code, the duration is 7 . Suppose you want someone to be reminded about an event or greetings 7 days after today which is 19th May . If the Emails you want to send are within the dates between 20th to 26th May , the recipient will receive the Email . Otherwise, it will not reach.
  • Then we put some commands to format the Email_Body . And also define the necessary parts of the Email by the With Statement .
  • We used the .Display command here so that Outlook will open these Email drafts and we can check if any other messages need to be sent. You can use the .Send command if you don’t want to see the message drafts. But do not use these two commands simultaneously .

  • Now, go back to your sheet and run the Macro named SendEmail02 as it is the name of your current Macro .

날짜를 기준으로 Excel에서 자동으로 이메일을 보내는 방법

  • After executing this operation, you will see a message box pop up telling you to select the date range . Select the range 확인을 클릭합니다. .

날짜를 기준으로 Excel에서 자동으로 이메일을 보내는 방법

  • Then, another message box will pop up and it will tell you to select the Email address range . Select the range 확인을 클릭합니다. .

날짜를 기준으로 Excel에서 자동으로 이메일을 보내는 방법

  • After that, select the range of text messages in the message box 확인을 클릭합니다. .

날짜를 기준으로 Excel에서 자동으로 이메일을 보내는 방법

  • You will see the Email drafts for 21st May to 24th May . Here, the ID admin@wsxdn.com is an actual Email ID , so we sent the corresponding Email to this address to show you the example. You can put a CC recipient if you want.

날짜를 기준으로 Excel에서 자동으로 이메일을 보내는 방법

  • Let’s check my Emails . This can be sent to Spam box too. So check everywhere.

날짜를 기준으로 Excel에서 자동으로 이메일을 보내는 방법

Thus you can automatically send email based on following dates

자세히 알아보기: Send Reminder Email Automatically from an Excel Worksheet Using VBA

유사한 수치

  • How to See Who Is in a Shared Excel File (With Quick Steps)
  • Enable Share Workbook in Excel
  • How to Share Excel File for Multiple Users
  • Send Bulk Email from Outlook Using Excel (3 Ways)
  • 첨부 파일이 있는 Excel에서 이메일을 보내기 위해 매크로를 적용하는 방법

3. Automatically Sending Email to a Single Address Based on a Date

We can also send an Email automatically single address based on a date . You can make a list of dates when you want to send the Emails to their corresponding recipients. Let’s go through the process below for a better understanding. In this section, we will only work with the dates .

단계:

  • First, go to Section 1 to see how to open a VBA Module .
  • Type the following code in the VBA Module .
Option Explicit
Sub SendEmail03()
Dim Date_Range As Range
Dim rng As Range
Set Date_Range = Range("B5:B10")
For Each rng In Date_Range
If rng.Value = Date Then
Dim Subject, Send_From, Send_To, _
Cc, Bcc, Body As String
Dim Email_Obj, Single_Mail As Variant
Subject = "Hello there!"
Send_From = "admin@wsxdn.com"
Send_To = "admin@wsxdn.com"
Cc = "admin@wsxdn.com"
Bcc = ""
Body = "Hope you are enjoying the article"
On Error GoTo debugs
Set Email_Obj = CreateObject("Outlook.Application")
Set Single_Mail = Email_Obj.CreateItem(0)
With Single_Mail
.Subject = Subject
.To = Send_To
.Cc = Cc
.Bcc = Bcc
.Body = Body
.send
End With
End If
Next
Exit Sub
debugs:
If Err.Description <> "" Then MsgBox Err.Description
End Sub

날짜를 기준으로 Excel에서 자동으로 이메일을 보내는 방법

Code Explanation

  • First, we declared some necessary variables:rng and Date_Range 범위로 .
  • Then we define the range for Date_Range .
  • After that, we use Value in a VBA IF Statement and also set Subject , Send_From , Send_To , Cc , Bcc and Body to String . Also, we set Email_Obj and Single_Mail as Variant .
  • Then we set the text value for Subject , Send_From , Send_To , Cc and Bcc .
  • Later, we create an Outlook Application Object which we define by Email_Obj . Also, we use Single_Mail 만들다 an item for Email_Obj .
  • After that, we define Subject , Send_To , Cc , Bcc , Body as the necessary parts of an Email by a With Statement . We also put the .Send command in this statement.

  • Now, go back to your sheet and run the Macro named SendEmail01 as it is the name of your current Macro .

날짜를 기준으로 Excel에서 자동으로 이메일을 보내는 방법

  • After that, you may see a warning box from Microsoft Outlook . Click Allow .

날짜를 기준으로 Excel에서 자동으로 이메일을 보내는 방법

This operation will send the Email to the addresses that you put in the corresponding message boxes .

This is the main Email .

날짜를 기준으로 Excel에서 자동으로 이메일을 보내는 방법

And below here is the Carbon Copy of the Email .

날짜를 기준으로 Excel에서 자동으로 이메일을 보내는 방법

Thus you can automatically send an Email from Excel based on the date . 

자세히 알아보기: How to Send Email Automatically When Condition Met in Excel

연습 섹션

In this section, I’m giving you the dataset that we used in this article so that you can practice on your own.

날짜를 기준으로 Excel에서 자동으로 이메일을 보내는 방법

기억해야 할 사항

Always open and log into your Outlook  account to run the VBA  codes in this article.

결론

The bottom line is, that you will learn effective methods on how to automatically send Email from Excel based on date . If you have any better ideas or feedback, please share them in the comment box. This will help me enrich my upcoming articles.

관련 기사

  • [Solved]:Share Workbook Not Showing in Excel (with Easy Steps)
  • Excel 목록에서 이메일을 보내는 방법(2가지 효과적인 방법)
  • How to Send an Editable Excel Spreadsheet by Email (3 Quick Methods)
  • Excel에서 이메일을 보내는 매크로(적합한 5가지 예)
  • 본문과 함께 Excel에서 이메일을 보내는 매크로(3가지 유용한 사례)
  • Excel Macro:Send Email to an Address in Cell (2 Easy Ways)