How to set up email to be sent via Excel for projects due within 7 days?Excel VBA - read cell value from code“Run-time error '13': Type Mismatch.” when there is no email addressCopy data from worksheet to html file to mailHow to preserve/retain hyperlinks in email body when using RangetoHTML from ExcelTake the date in one worksheet and find the same date in another worksheet column and return the cell reference for that date to use in a loopTrying to create personalized emails with multiple attachmentsExcel VBA macro to send emails to unique users in rangeexcel VBA code to ignore an email attachment if missing from folderSend email if today's date is within four days of a due dateExcel: Send outlook email based on cell content

Intersection point of 2 lines defined by 2 points each

Is it possible to do 50 km distance without any previous training?

What does it mean to describe someone as a butt steak?

infared filters v nd

How can bays and straits be determined in a procedurally generated map?

How does one intimidate enemies without having the capacity for violence?

What does "Puller Prush Person" mean?

Important Resources for Dark Age Civilizations?

Cross compiling for RPi - error while loading shared libraries

DC-DC converter from low voltage at high current, to high voltage at low current

Modeling an IP Address

tikz convert color string to hex value

Why are electrically insulating heatsinks so rare? Is it just cost?

How is the claim "I am in New York only if I am in America" the same as "If I am in New York, then I am in America?

Why is consensus so controversial in Britain?

Could an aircraft fly or hover using only jets of compressed air?

Is it inappropriate for a student to attend their mentor's dissertation defense?

How is it possible to have an ability score that is less than 3?

How old can references or sources in a thesis be?

Revoked SSL certificate

I'm flying to France today and my passport expires in less than 2 months

Can I ask the recruiters in my resume to put the reason why I am rejected?

Java Casting: Java 11 throws LambdaConversionException while 1.8 does not

Is it unprofessional to ask if a job posting on GlassDoor is real?



How to set up email to be sent via Excel for projects due within 7 days?


Excel VBA - read cell value from code“Run-time error '13': Type Mismatch.” when there is no email addressCopy data from worksheet to html file to mailHow to preserve/retain hyperlinks in email body when using RangetoHTML from ExcelTake the date in one worksheet and find the same date in another worksheet column and return the cell reference for that date to use in a loopTrying to create personalized emails with multiple attachmentsExcel VBA macro to send emails to unique users in rangeexcel VBA code to ignore an email attachment if missing from folderSend email if today's date is within four days of a due dateExcel: Send outlook email based on cell content






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















Image of Spreadsheet



I am trying set up email notifications to be sent people in my department whenever there is an upcoming due date within 7 days. Currently the issue is whenever I run the module, it sets up emails for anything that is before the due date. However, I want emails to be set up for projects that are due within 7 days. So if the project is 10 days out, I do not want an email sent, same project where it is already past due.



In addition, I would like the emails to be sent to the person responsible of the project, but not if they have indicated that they already completed the project in Column I.



I have Project names in Column B, Emails in Column F, Due Dates in Column H, and Column K would show "Email Sent" if the script sends the email. If the email has already been sent previously then it would skip that row.



Private Sub Workbook_Open()
Dim OutApp As Object
Dim OutMail As Object
Dim lLastRow As Long
Dim lRow As Long
Dim sSendTo As String
Dim sSendCC As String
Dim sSendBCC As String
Dim sSubject As String
Dim sTemp As String

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon

' Change the following as needed
sSendCC = ""
sSendBCC = ""
sSubject = "Project Log Due Date Reached"

lLastRow = Cells(Rows.Count, 3).End(xlUp).Row
For lRow = 3 To lLastRow
If Cells(lRow, 11) <> "Email Sent" Then
If Cells(lRow, 8) - Date <= 7 And Cells(1Row, 8) - Date > 0 Then
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
.To = Cells(1Row, 6)
If sSendCC > "" Then .CC = sSendCC
If sSendBCC > "" Then .BCC = sSendBCC
.Subject = sSubject

sTemp = "Hello!" & vbCrLf & vbCrLf
sTemp = sTemp & "The due date has been reached "
sTemp = sTemp & "for this project:" & vbCrLf & vbCrLf
' Assumes project name is in column B
sTemp = sTemp & " " & Cells(lRow, 2)
sTemp = sTemp & "Please take the appropriate"
sTemp = sTemp & "action." & vbCrLf & vbCrLf
sTemp = sTemp & "Thank you!" & vbCrLf

.Body = sTemp
' Change the following to .Send if you want to
' send the message without reviewing first
.Send
End With
Set OutMail = Nothing

Cells(lRow, 11) = "Email Sent"
Cells(lRow, 12) = "E-mail sent on: " & Now()
End If
End If
Next lRow
Set OutApp = Nothing
End Sub









share|improve this question
























  • Can you edit your question - link here - and specify what problem(s) you are having?

    – BigBen
    Mar 8 at 1:49











  • And add some sample data

    – Ricardo Diaz
    Mar 8 at 2:06











  • and get rid of this: On Error Resume Next there's no need for it in this code and it will hide real issues that may arise and can be handled differently .... in this line :If Cells(lRow, 7) <= 7 Then, are you sure you have the right math in column G to calculate the days?

    – Scott Holtzman
    Mar 8 at 2:31


















0















Image of Spreadsheet



I am trying set up email notifications to be sent people in my department whenever there is an upcoming due date within 7 days. Currently the issue is whenever I run the module, it sets up emails for anything that is before the due date. However, I want emails to be set up for projects that are due within 7 days. So if the project is 10 days out, I do not want an email sent, same project where it is already past due.



In addition, I would like the emails to be sent to the person responsible of the project, but not if they have indicated that they already completed the project in Column I.



I have Project names in Column B, Emails in Column F, Due Dates in Column H, and Column K would show "Email Sent" if the script sends the email. If the email has already been sent previously then it would skip that row.



Private Sub Workbook_Open()
Dim OutApp As Object
Dim OutMail As Object
Dim lLastRow As Long
Dim lRow As Long
Dim sSendTo As String
Dim sSendCC As String
Dim sSendBCC As String
Dim sSubject As String
Dim sTemp As String

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon

' Change the following as needed
sSendCC = ""
sSendBCC = ""
sSubject = "Project Log Due Date Reached"

lLastRow = Cells(Rows.Count, 3).End(xlUp).Row
For lRow = 3 To lLastRow
If Cells(lRow, 11) <> "Email Sent" Then
If Cells(lRow, 8) - Date <= 7 And Cells(1Row, 8) - Date > 0 Then
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
.To = Cells(1Row, 6)
If sSendCC > "" Then .CC = sSendCC
If sSendBCC > "" Then .BCC = sSendBCC
.Subject = sSubject

sTemp = "Hello!" & vbCrLf & vbCrLf
sTemp = sTemp & "The due date has been reached "
sTemp = sTemp & "for this project:" & vbCrLf & vbCrLf
' Assumes project name is in column B
sTemp = sTemp & " " & Cells(lRow, 2)
sTemp = sTemp & "Please take the appropriate"
sTemp = sTemp & "action." & vbCrLf & vbCrLf
sTemp = sTemp & "Thank you!" & vbCrLf

.Body = sTemp
' Change the following to .Send if you want to
' send the message without reviewing first
.Send
End With
Set OutMail = Nothing

Cells(lRow, 11) = "Email Sent"
Cells(lRow, 12) = "E-mail sent on: " & Now()
End If
End If
Next lRow
Set OutApp = Nothing
End Sub









share|improve this question
























  • Can you edit your question - link here - and specify what problem(s) you are having?

    – BigBen
    Mar 8 at 1:49











  • And add some sample data

    – Ricardo Diaz
    Mar 8 at 2:06











  • and get rid of this: On Error Resume Next there's no need for it in this code and it will hide real issues that may arise and can be handled differently .... in this line :If Cells(lRow, 7) <= 7 Then, are you sure you have the right math in column G to calculate the days?

    – Scott Holtzman
    Mar 8 at 2:31














0












0








0








Image of Spreadsheet



I am trying set up email notifications to be sent people in my department whenever there is an upcoming due date within 7 days. Currently the issue is whenever I run the module, it sets up emails for anything that is before the due date. However, I want emails to be set up for projects that are due within 7 days. So if the project is 10 days out, I do not want an email sent, same project where it is already past due.



In addition, I would like the emails to be sent to the person responsible of the project, but not if they have indicated that they already completed the project in Column I.



I have Project names in Column B, Emails in Column F, Due Dates in Column H, and Column K would show "Email Sent" if the script sends the email. If the email has already been sent previously then it would skip that row.



Private Sub Workbook_Open()
Dim OutApp As Object
Dim OutMail As Object
Dim lLastRow As Long
Dim lRow As Long
Dim sSendTo As String
Dim sSendCC As String
Dim sSendBCC As String
Dim sSubject As String
Dim sTemp As String

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon

' Change the following as needed
sSendCC = ""
sSendBCC = ""
sSubject = "Project Log Due Date Reached"

lLastRow = Cells(Rows.Count, 3).End(xlUp).Row
For lRow = 3 To lLastRow
If Cells(lRow, 11) <> "Email Sent" Then
If Cells(lRow, 8) - Date <= 7 And Cells(1Row, 8) - Date > 0 Then
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
.To = Cells(1Row, 6)
If sSendCC > "" Then .CC = sSendCC
If sSendBCC > "" Then .BCC = sSendBCC
.Subject = sSubject

sTemp = "Hello!" & vbCrLf & vbCrLf
sTemp = sTemp & "The due date has been reached "
sTemp = sTemp & "for this project:" & vbCrLf & vbCrLf
' Assumes project name is in column B
sTemp = sTemp & " " & Cells(lRow, 2)
sTemp = sTemp & "Please take the appropriate"
sTemp = sTemp & "action." & vbCrLf & vbCrLf
sTemp = sTemp & "Thank you!" & vbCrLf

.Body = sTemp
' Change the following to .Send if you want to
' send the message without reviewing first
.Send
End With
Set OutMail = Nothing

Cells(lRow, 11) = "Email Sent"
Cells(lRow, 12) = "E-mail sent on: " & Now()
End If
End If
Next lRow
Set OutApp = Nothing
End Sub









share|improve this question
















Image of Spreadsheet



I am trying set up email notifications to be sent people in my department whenever there is an upcoming due date within 7 days. Currently the issue is whenever I run the module, it sets up emails for anything that is before the due date. However, I want emails to be set up for projects that are due within 7 days. So if the project is 10 days out, I do not want an email sent, same project where it is already past due.



In addition, I would like the emails to be sent to the person responsible of the project, but not if they have indicated that they already completed the project in Column I.



I have Project names in Column B, Emails in Column F, Due Dates in Column H, and Column K would show "Email Sent" if the script sends the email. If the email has already been sent previously then it would skip that row.



Private Sub Workbook_Open()
Dim OutApp As Object
Dim OutMail As Object
Dim lLastRow As Long
Dim lRow As Long
Dim sSendTo As String
Dim sSendCC As String
Dim sSendBCC As String
Dim sSubject As String
Dim sTemp As String

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon

' Change the following as needed
sSendCC = ""
sSendBCC = ""
sSubject = "Project Log Due Date Reached"

lLastRow = Cells(Rows.Count, 3).End(xlUp).Row
For lRow = 3 To lLastRow
If Cells(lRow, 11) <> "Email Sent" Then
If Cells(lRow, 8) - Date <= 7 And Cells(1Row, 8) - Date > 0 Then
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
.To = Cells(1Row, 6)
If sSendCC > "" Then .CC = sSendCC
If sSendBCC > "" Then .BCC = sSendBCC
.Subject = sSubject

sTemp = "Hello!" & vbCrLf & vbCrLf
sTemp = sTemp & "The due date has been reached "
sTemp = sTemp & "for this project:" & vbCrLf & vbCrLf
' Assumes project name is in column B
sTemp = sTemp & " " & Cells(lRow, 2)
sTemp = sTemp & "Please take the appropriate"
sTemp = sTemp & "action." & vbCrLf & vbCrLf
sTemp = sTemp & "Thank you!" & vbCrLf

.Body = sTemp
' Change the following to .Send if you want to
' send the message without reviewing first
.Send
End With
Set OutMail = Nothing

Cells(lRow, 11) = "Email Sent"
Cells(lRow, 12) = "E-mail sent on: " & Now()
End If
End If
Next lRow
Set OutApp = Nothing
End Sub






excel vba






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 18:54







Seany

















asked Mar 8 at 1:47









SeanySeany

11




11












  • Can you edit your question - link here - and specify what problem(s) you are having?

    – BigBen
    Mar 8 at 1:49











  • And add some sample data

    – Ricardo Diaz
    Mar 8 at 2:06











  • and get rid of this: On Error Resume Next there's no need for it in this code and it will hide real issues that may arise and can be handled differently .... in this line :If Cells(lRow, 7) <= 7 Then, are you sure you have the right math in column G to calculate the days?

    – Scott Holtzman
    Mar 8 at 2:31


















  • Can you edit your question - link here - and specify what problem(s) you are having?

    – BigBen
    Mar 8 at 1:49











  • And add some sample data

    – Ricardo Diaz
    Mar 8 at 2:06











  • and get rid of this: On Error Resume Next there's no need for it in this code and it will hide real issues that may arise and can be handled differently .... in this line :If Cells(lRow, 7) <= 7 Then, are you sure you have the right math in column G to calculate the days?

    – Scott Holtzman
    Mar 8 at 2:31

















Can you edit your question - link here - and specify what problem(s) you are having?

– BigBen
Mar 8 at 1:49





Can you edit your question - link here - and specify what problem(s) you are having?

– BigBen
Mar 8 at 1:49













And add some sample data

– Ricardo Diaz
Mar 8 at 2:06





And add some sample data

– Ricardo Diaz
Mar 8 at 2:06













and get rid of this: On Error Resume Next there's no need for it in this code and it will hide real issues that may arise and can be handled differently .... in this line :If Cells(lRow, 7) <= 7 Then, are you sure you have the right math in column G to calculate the days?

– Scott Holtzman
Mar 8 at 2:31






and get rid of this: On Error Resume Next there's no need for it in this code and it will hide real issues that may arise and can be handled differently .... in this line :If Cells(lRow, 7) <= 7 Then, are you sure you have the right math in column G to calculate the days?

– Scott Holtzman
Mar 8 at 2:31













2 Answers
2






active

oldest

votes


















0














Please make a helper column in free column say Land put the formula =TODAY()-G2and draw down. Replace your following lines



 For lRow = 3 To lLastRow
If Cells(lRow, 10) <> "Email Sent" Then
If Cells(lRow, 7) <= 7 Then
Set OutMail = OutApp.CreateItem(0)


With



For lRow = 3 To lLastRow
If Cells(lRow, 10) <> "Email Sent" Then
If (Cells(lRow, 12) >= -7) And (Cells(lRow, 12) <= 0) Then
Set OutMail = OutApp.CreateItem(0)


It works for me. You can also follow any other logic based on this logic.






share|improve this answer
































    0














    Seany, Scott's right - take out the "On Error Resume Next" statement as this suppresses errors you'd rather see and troubleshoot at design time. And, you said Column F; which when using the Cells property, the column is the second parameter and you have "7" where "F" would be "6."



    For comparing dates, I'd suggest DateDiff



    Ex:



    DateDiff("d", ws.Cells(1, 1).Value, ws.Cells(1, 1).Value + 7)





    share|improve this answer

























      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55055584%2fhow-to-set-up-email-to-be-sent-via-excel-for-projects-due-within-7-days%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      Please make a helper column in free column say Land put the formula =TODAY()-G2and draw down. Replace your following lines



       For lRow = 3 To lLastRow
      If Cells(lRow, 10) <> "Email Sent" Then
      If Cells(lRow, 7) <= 7 Then
      Set OutMail = OutApp.CreateItem(0)


      With



      For lRow = 3 To lLastRow
      If Cells(lRow, 10) <> "Email Sent" Then
      If (Cells(lRow, 12) >= -7) And (Cells(lRow, 12) <= 0) Then
      Set OutMail = OutApp.CreateItem(0)


      It works for me. You can also follow any other logic based on this logic.






      share|improve this answer





























        0














        Please make a helper column in free column say Land put the formula =TODAY()-G2and draw down. Replace your following lines



         For lRow = 3 To lLastRow
        If Cells(lRow, 10) <> "Email Sent" Then
        If Cells(lRow, 7) <= 7 Then
        Set OutMail = OutApp.CreateItem(0)


        With



        For lRow = 3 To lLastRow
        If Cells(lRow, 10) <> "Email Sent" Then
        If (Cells(lRow, 12) >= -7) And (Cells(lRow, 12) <= 0) Then
        Set OutMail = OutApp.CreateItem(0)


        It works for me. You can also follow any other logic based on this logic.






        share|improve this answer



























          0












          0








          0







          Please make a helper column in free column say Land put the formula =TODAY()-G2and draw down. Replace your following lines



           For lRow = 3 To lLastRow
          If Cells(lRow, 10) <> "Email Sent" Then
          If Cells(lRow, 7) <= 7 Then
          Set OutMail = OutApp.CreateItem(0)


          With



          For lRow = 3 To lLastRow
          If Cells(lRow, 10) <> "Email Sent" Then
          If (Cells(lRow, 12) >= -7) And (Cells(lRow, 12) <= 0) Then
          Set OutMail = OutApp.CreateItem(0)


          It works for me. You can also follow any other logic based on this logic.






          share|improve this answer















          Please make a helper column in free column say Land put the formula =TODAY()-G2and draw down. Replace your following lines



           For lRow = 3 To lLastRow
          If Cells(lRow, 10) <> "Email Sent" Then
          If Cells(lRow, 7) <= 7 Then
          Set OutMail = OutApp.CreateItem(0)


          With



          For lRow = 3 To lLastRow
          If Cells(lRow, 10) <> "Email Sent" Then
          If (Cells(lRow, 12) >= -7) And (Cells(lRow, 12) <= 0) Then
          Set OutMail = OutApp.CreateItem(0)


          It works for me. You can also follow any other logic based on this logic.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 8 at 4:46

























          answered Mar 8 at 4:28









          skkakkarskkakkar

          2,3112924




          2,3112924























              0














              Seany, Scott's right - take out the "On Error Resume Next" statement as this suppresses errors you'd rather see and troubleshoot at design time. And, you said Column F; which when using the Cells property, the column is the second parameter and you have "7" where "F" would be "6."



              For comparing dates, I'd suggest DateDiff



              Ex:



              DateDiff("d", ws.Cells(1, 1).Value, ws.Cells(1, 1).Value + 7)





              share|improve this answer





























                0














                Seany, Scott's right - take out the "On Error Resume Next" statement as this suppresses errors you'd rather see and troubleshoot at design time. And, you said Column F; which when using the Cells property, the column is the second parameter and you have "7" where "F" would be "6."



                For comparing dates, I'd suggest DateDiff



                Ex:



                DateDiff("d", ws.Cells(1, 1).Value, ws.Cells(1, 1).Value + 7)





                share|improve this answer



























                  0












                  0








                  0







                  Seany, Scott's right - take out the "On Error Resume Next" statement as this suppresses errors you'd rather see and troubleshoot at design time. And, you said Column F; which when using the Cells property, the column is the second parameter and you have "7" where "F" would be "6."



                  For comparing dates, I'd suggest DateDiff



                  Ex:



                  DateDiff("d", ws.Cells(1, 1).Value, ws.Cells(1, 1).Value + 7)





                  share|improve this answer















                  Seany, Scott's right - take out the "On Error Resume Next" statement as this suppresses errors you'd rather see and troubleshoot at design time. And, you said Column F; which when using the Cells property, the column is the second parameter and you have "7" where "F" would be "6."



                  For comparing dates, I'd suggest DateDiff



                  Ex:



                  DateDiff("d", ws.Cells(1, 1).Value, ws.Cells(1, 1).Value + 7)






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Mar 25 at 23:32









                  Wai Ha Lee

                  6,126124166




                  6,126124166










                  answered Mar 8 at 3:50









                  J VBAJ VBA

                  16715




                  16715



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55055584%2fhow-to-set-up-email-to-be-sent-via-excel-for-projects-due-within-7-days%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      1928 у кіно

                      Захаров Федір Захарович

                      Ель Греко