+ Reply to Thread
Results 1 to 3 of 3

Sending an e-mail automatically through to people when a due date is approaching

  1. #1
    Registered User
    Join Date
    03-25-2013
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    2

    Red face Sending an e-mail automatically through to people when a due date is approaching

    Hi all,
    I am new to the site but am hoping that you can help me. BTW thanks for being accessible!
    I have created a macro that looks at today's date and a cell in Column A and conditionally formats the cell red if it is overdue.
    The next step that I would like to take is to extend on this macro so that I can send out an e-mail to a person with the name of the task in the subject matter explaining that the date has passed.
    I have seen a number of posts on this but was hoping that someone could assist with the script AND indicate in a different font what each of the sections do like when you step into the macro.
    I hope that this makes sense - please let me know if you have any questions.
    I have found the previous post http://www.excelforum.com/excel-prog...-in-excel.html helpful but not sure what each of the sections mean!

    Thanks in advance for your help,

  2. #2
    Registered User
    Join Date
    03-25-2013
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Sending an e-mail automatically through to people when a due date is approaching

    Hi Guys, I didn't get any response so I gave it a go..
    The script is working but I need to push the boundaries now so that I can create a follow up flag on the e-mail just like it is re. importance.
    I have taken the following attempt:
    Sub This_is_the_one_that_is_to_be_used()
    '
    ' This_is_the_one_that_is_to_be_used Macro
    ' Macro recorded 3/05/2013 by Mirella Faccioni
    '
    ' Keyboard Shortcut: Ctrl+Shift+N
    'Range(Selection, Selection.End(xlDown)).Select
    Range("U5:U96").Select
    Selection.FormatConditions.Delete
    Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
    Formula1:="=$C$3"
    Selection.FormatConditions(1).Interior.ColorIndex = 3

    Dim ce As Range, i As Long
    Dim OutApp As Object
    Dim OutMail As Object
    Dim strto As String, strcc As String, strbcc As String
    Dim strsub As String, strbody As String
    For i = 1 To Sheets("Data").Range("e30").End(xlUp).Row
    If Cells(i, 21).Value < Date Then
    Set OutApp = CreateObject("Outlook.Application")
    OutApp.Session.Logon
    Set OutMail = OutApp.CreateItem(0)

    With Sheets("Data")
    strto = .Cells(i, 1).Value
    strcc = ""
    strbcc = ""
    importance = 2
    ReminderSet = True
    FlagRequest = "Follow Up"
    FlagDueBy = Cells(i, 21).Value

    strsub = "Overdue notice for store" & " " & .Cells(i, 4).Value

    strbody = "Hi" & " " & vbNewLine & vbNewLine & _
    "Your next action" & " " & .Cells(i, 20).Value & " " & _
    "for store" & " " & .Cells(i, 4).Value & " " & _
    "has expired on" & " " & .Cells(i, 21).Value & _
    " " & vbNewLine & vbNewLine & _
    "Please contact store or take immediate action......" & " " & _
    vbCrLf & vbCrLf & "Thank you."
    .Cells(i, 6) = Now()
    End With

    With OutMail
    .To = strto
    .CC = strcc
    .BCC = strbcc
    .Subject = strsub
    .Body = strbody
    .display
    .importance = importance
    .ReminderSet = True
    .FlagRequest = "Follow Up"
    .FlagDueBy = Cells(i, 21).Value

    End With

    Set OutMail = Nothing
    Set OutApp = Nothing
    ElseIf Cells(i, 21).Value < Date + 5 Then
    Set OutApp = CreateObject("Outlook.Application")
    OutApp.Session.Logon
    Set OutMail = OutApp.CreateItem(0)

    With Sheets("Data")
    strto = .Cells(i, 1).Value
    strcc = ""
    strbcc = ""

    strsub = "Reminder notice for store" & " " & .Cells(i, 4).Value
    strbody = "Hi" & " " & vbNewLine & vbNewLine & _
    "Your next action" & " " & .Cells(i, 20).Value & " " & _
    "for store" & " " & .Cells(i, 4).Value & " " & _
    "is due to expire on" & " " & .Cells(i, 21).Value & _
    " " & vbNewLine & vbNewLine & _
    "Please contact store or take immediate action so as not to lose the opportunity" & _
    vbNewLine & vbNewLine & "Thank you."
    .Cells(i, 6) = Now()
    End With

    With OutMail
    .To = strto
    .CC = strcc
    .BCC = strbcc
    .Subject = strsub
    .Body = strbody
    .importance = importance
    .display
    .ReminderSet = True
    .FlagRequest = "Follow Up"
    .FlagDueBy = Cells(i, 21).Value



    End With

    Set OutMail = Nothing
    Set OutApp = Nothing

    End If
    Next i
    End Sub

    PLEASE can someone help me to resolve this as it would help our teams enormously and I am sure it is a simple thing (just not for me)
    Thanks,

  3. #3
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: Sending an e-mail automatically through to people when a due date is approaching

    You will increase your chances tremendously (and keep the mods off you) if you will properly enclose your code with code tags. If you are unsure how to do so, please read the FAQ's.
    Perhaps it was the Noid who should have avoided me...
    If you are satisfied with my solution click the small star icon on the left. Thanks
    1. Make a copy of your workbook and run the following code on your copy (just in case)
    2. With excel open, press ALT+F11 to open the Visual Basic Editor (VBE). From the "Insert" menu, select "Module".
    3. Paste the code from above into the empty white space. Close the VBE.
    4. From the developer tab, choose "Macros", select the Sub Name, and click "Run".

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1