Solved

Sending email notification using dates in Excel

Posted on 2015-01-19
2
282 Views
Last Modified: 2015-01-23
Hello,

Pl refer to the attached sheet. What am trying to do is I want that Excel sends email notification 30 days before the Expiry date in the field D to the email IDs in field F. I have done some backend scripting taking lead from few websites but its not working so turned to Expert Exchange.!

Can someone help. It would be great if the email subject picks up name of the document in from cell B.

Thanks
Myinfo
SOP-TRACKER.xlsm
0
Comment
Question by:Advait Kawthalkar
2 Comments
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 40559135
Hi,

pls try (first code send an email to everybody and 2nd an email to each address

Sub SendReminderMail()
Dim OutlookApp As Object
Dim OutLookMailItem As Object
Dim iCounter As Integer
Dim MailDest As String
Dim Documents As String


Set OutlookApp = CreateObject("Outlook.application")
Set OutLookMailItem = OutlookApp.CreateItem(0)

With OutLookMailItem
    MailDest = ""
    Documents = ""
    For Each cell In Range(Range("F2"), Range("F" & Cells.Rows.Count).End(xlUp))
        If cell.Offset(0, -2) = "Expires next month" Then
            MailDest = cell.Value & ";"
            Documents = cell.Offset(0, -4).Value & ", "
        End If
    Next
    MailDest = Left(MailDest, Len(MailDest) - 1)
    Documents = Left(Documents, Len(Documents) - 2)
    
    .BCC = MailDest
    .Subject = "Your SOP is expiring (" & Documents & ")"
    .Body = "Reminder : Your SOP is going to expire in a month"
    .Display ' .Send
End With

Set OutLookMailItem = Nothing
Set OutlookApp = Nothing

End Sub
Sub SendReminderMail1()

End Sub
Dim OutlookApp As Object
Dim OutLookMailItem As Object
Dim iCounter As Integer
Dim MailDest As String
Dim Documents As String


Set OutlookApp = CreateObject("Outlook.application")
Set OutLookMailItem = OutlookApp.CreateItem(0)

With OutLookMailItem
    MailDest = ""
    Documents = ""
    For Each cell In Range(Range("F2"), Range("F" & Cells.Rows.Count).End(xlUp))
        If cell.Offset(0, -2) = "Expires next month" Then
            MailDest = cell.Value
            Documents = cell.Offset(0, -4).Value
        End If
    
        .BCC = MailDest
        .Subject = "Your SOP is expiring (" & Documents & ")"
        .Body = "Reminder : Your SOP is going to expire in a month"
        .Display ' .Send
        Next
End With

Set OutLookMailItem = Nothing
Set OutlookApp = Nothing

Open in new window

Regards
0
 

Author Closing Comment

by:Advait Kawthalkar
ID: 40567690
Thanks Rgonzo1971
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
: Microsoft Office Collaborate for free and online versions of Microsoft  Word, Excel, Powerpoint, OneNote, Onedrive , Email, Calendar etc. In short we can say that Microsoft office is a suite of servers, applications and services developed by  Micr…
Video by: Zack
Viewers will learn about various customizable options in Excel 2013.
Viewers will learn the basics of using filtering and sorting in Excel 2013.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question