• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Send Automated Email - Due Date

ianb

Member
send automated emails to contract owners ( Column "Q") as soon as the contract is due ( Column "O") based on the review date(Column "P")

CELL O Notice Period
CELL P Review Contract by
CELL Q Contract Owner


CELL O 90
CELL P 03-Jul-14
CELL Q purchasing@domain.com


If Today is = or > than P2 then send email.
 
Last edited by a moderator:
Hi, ianb!

More than 250 posts, not a newbie any more, so would you be as kind as to tell us if you've yet performed a search within these forums, or if you've gone thru this (and its sublinks):
http://www.rondebruin.nl/win/section1.htm
http://www.rondebruin.nl/win/section1.htm
If done so and nothing useful found, consider uploading a sample file (including manual examples of desired output if applicable), it'd be very useful for those who read this and might be able to help you. Thank you.

Regards!
 
Hi SirJB. Has beena while. I have a few ideas about this one and just wanted to ask to see if any one selse had any ideas. Thanks for the link. will check this out and post when I am my sheet operation. Do like the like POST PDF which is triggering more ideas. thanks for the advise and time as always. Ian.
 
Hi, ianb!
Nice to read you again. Regarding your think-tank on sending mail, practically the whole number of variations is covered at the posted page, so give it a try whenever you can and welcome back.
Regards!
 
Hi JB. I have finished my Spreadsheet. Can you look at this as I would like to :

a) If no changes when opened via a schedule will send an email to myself confirming no changes for today
b) Will open update, send emails and close sending emails and an email to myself stating how many emails have been sent today.

When run on a schedule each day will simply from a user point view, open (do magic!) then close.

most of it is finished. just need that little touch of magic !!

Can I send this spreadsheet to you please. thank you.
 
Last edited:
ianb

Instead of asking members to go to another site to look at your work book why do you not use the "Upload a File" button.
 
Hi, ianb!

The code looks quite clean and like a standard mail sending procedure using Outlook so I think it should work fine.

Now, about your questions:
a) Specify in detail what do you define as a change, what do you mean by open via a schedule, your mail is that of column D or it's the hardcoded address within the code?
b) Clarify what update is, if it will be run only once a day or more than once, if this last then how would you count the total no. of mails in a day?

Regards!
 
Hi, I was thinking. when the spredsheet runs each day (In the morning) if any changes (from Not Sent to Sent) in column C then an email would be sent to myself to confirm you have sent (e.g.) 2 emails today or you have sent 0 emails today as it would run once each day via a windows schedule and the email would confirm that the schedule had been run.

A copy of the email sent to the person would be sent via a CC which I have included in the code. Then the confirmation of the process had run with a summary would be sent via email also. Does this sound like the best idea to confirm completion of the daily task ?
 
Last edited by a moderator:
Hi, ianb!

Let me resume the process so as to check if I understood it correctly:
a) You have a daily scheduled task that runs Excel, opening this workbook.
b) You want to automatically trigger a process that checks column C for "Not Sent", fires a mail for the address in column D with copy to the hardcoded address and updates column C to "Sent".
c) You want a summary mail to be send to you with the total no. of mails sent.

Regards!
 
Hi Sir JB7,
a) Yes - Will open, update and close.... except if a person needs to add data.
b) Yes - I have done this at it will automatically update when sending the emails out including my cc copy.
c) Yes - A summary stating you have sent 0 emails today or you have sent 2 emails today.
 
a) I was thinking a schedule to run .vbs to open excel and run the macros else another .vbs to just open in thisworksheet.
b) completed.!
c) do you have any ideas on this one.?
 
Hi, ianb!
a) So the procedure that will do the job won't be automatically run at open time; it's up to you to run it from a VB script, off the Excel file.
b) Ok.
c) No, as long as you don't have a column for holding the mail date; and if you had, what about the times that the scheduled task doesn't run for any reason? How would you control 2 or more accumulated days?
Regards!
 
Hi JB7,

a) Yes Simple way. Open or Open, Update and Close
c) You have given me the idea. When Column : Email Sent C changes then place todays date in a new column.
Then in the new column would be if todays date then count giving me the mails sent for today 0 or X

or another way would be to have the emails sent moved to a folder via an excel prorgram (I have loads of move email programs) then count the emails for today (loads of these programs too) and finally send an email with the count in (loads of these programs too!!!!) The Olde MOVE, COUNT and SEND...

Thanks for the guidance...!! Ian.
 
Hi, ianb!
a) Ok, the scheduled script will run the macro, nothing done at open time within the open event code section of the workbook class module.
c) No problem with the new date column, I just didn't know if it could be created. The "other way", no way, unless you want to receive my bill in Euros, just 4 digits and starting with a 1 and all the other 0.
Regards!
 
Hi, ianb!

Give a look at the uploaded file. It uses a named range for the last time that the procedure was run, and a column to hold the mail sending date, column Q:
MailLastDateCell: ='Customer Renewal'!$Q$1

You should build the VB script that opens this file and run the procedure:
IWantMySixPackOfCarlsbergIWantItAllAndIWantItNow()

This is the code, based on the previously provided by you. It isn't tested, leave you as your homework:
Code:
Option Explicit

Sub IWantMySixPackOfCarlsbergIWantItAllAndIWantItNow()
    '
    ' constants
    Const ksWS = "Customer Renewal"
    Const ksMailLastDate = "MailLastDateCell"
    Const kiMailStatus = 3
    Const ksMailAddress = 4
    Const kiMailDate = 17
    Const ksMailStatusChanged = "Not Sent"
    Const ksMailStatusUpdated = "Sent"
    Const ksMailBCC = "purchasing@.co.uk"
    Const ksMailAttachment = "C:\Renewal\CustRenewal.docx"
    Const ksMailMe = "pirulito@.co.uk"
    '
    ' declarations
    '  general
    Dim dMailLastDate As Date, iMailSent As Integer
    Dim I As Long, J As Integer
    '  outlook
    Dim OutApp As Object, OutMail As Object
    Dim strTo As String, strCC As String, strBCC As String
    Dim strSub As String, strBody As String, strAttachment As String
    '
    ' start
    '  general
    dMailLastDate = Worksheets(ksWS).Range(ksMailLastDate).Cells(1, 1).Value
    iMailSent = 0
    '  outlook
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
    '
    ' process
    With Worksheets(ksWS)
        ' check changes
        I = 3
        Do Until .Cells(I, 1).Value = ""
            ' send mail
            If .Cells(I, kiMailStatus).Value = ksMailStatusChanged Then
                strTo = .Cells(I, 4).Value
                strCC = ""
                strBCC = ksMailBCC
                strSub = "Contract Renewal Number : " & _
                    .Cells(I, 1).Value & " - " & .Cells(I, 9).Value
                strBody = "Dear " & .Cells(I, 8).Value & vbNewLine & vbNewLine & _
                    "The renewal/notice for termination date for the above contract was reached on " & _
                    Format(.Cells(I, 6).Value, "dd/mm/yyyy") & vbNewLine & vbNewLine & _
                    "Please take the necessary action within 30 calendar days to either renew or terminate this contract." & _
                    vbNewLine & vbNewLine & _
                    "Kind Regards," & vbNewLine & vbNewLine & _
                    "Mangala Wickramasinghe." & vbNewLine & _
                    "Finance Department"
                strAttachment = ksMailAttachment
                With OutMail
                    .To = strTo
                    .CC = strCC
                    .BCC = strBCC
                    .Subject = strSub
                    .Body = strBody
                    'You can add a file to the mail
                    If strAttachment <> "" Then .Attachments.Add (strAttachment)
                    'Change This from Display to Send to Automatically Send
                    .Display
                    '.Send
                End With
                .Cells(I, kiMailDate).Value = Now() 'Int(Now()) if don't want h:m:s
            End If
            ' count changes
            If .Cells(I, kiMailDate).Value > dMailLastDate Then iMailSent = iMailSent + 1
            ' cycle
            I = I + 1
        Loop
        ' send summary mail
        strTo = ksMailMe
        strCC = ""
        strBCC = ksMailBCC
        strSub = "Contract Renewal - Daily sent mails summary: " & Now() & " : " & iMailSent & " mails"
        strBody = strSub
        strAttachment = ""
        With OutMail
            .To = strTo
            .CC = strCC
            .BCC = strBCC
            .Subject = strSub
            .Body = strBody
            'You can add a file to the mail
            If strAttachment <> "" Then .Attachments.Add (strAttachment)
            'Change This from Display to Send to Automatically Send
            .Display
            '.Send
        End With
    End With
    '
    ' end
    '  outlook
    Set OutMail = Nothing
    Set OutApp = Nothing
    '  general
    Worksheets(ksWS).Range(ksMailLastDate).Cells(1, 1).Value = Now()
    Beep
    '
End Sub

Just advise if any issue.

Regards!
 
Back
Top