Solved

Sending email notification using dates in Excel

Posted on 2015-01-19
2
249 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Note: This is the third blog post in a series on email clearinghouses (https://www.xmatters.com/alert-management/blog-email-has-failed-us?utm_campaign=70138000000ydLoAAI&utm_source=exex&utm_medium=article&utm_content=blog-post).   We’ve been talki…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Viewers will learn a basic relationship technique in Power Pivot for Excel 2013.
Viewers will learn the basics of printing in Excel 2013 and how to adjust some common settings.

920 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now