Send email depending on cell values

j844929

Active Member
Joined
Aug 18, 2002
Messages
423
Hi,

I thought I had solved this, but actually, I was nowhere even close...and the entire success of my spreadsheet's effectiveness depends on it....

Does anyone know the code to send an email to a set list of six recipients when cells in a certain column in a worksheet reach a certain value greater than another. Let me explain a little - The action to be performed is date-based.

For Example:

When the date cell L2 is 30 days later than the date in K2, send an email with subject containing data from cells B2 and C3.

However, this has to work for columns K and L in their entirety, as both columns contain a list of dates...

Hope someone can help.

Tim
 
Try this, change the email address, not sure about a mailing list, I've never tried it, let me know if it works;

Code:
Sub Over_30_days_Mail()

'You need to Reference Outlook
'Goto Tools>References and select Microsoft Outlook Libary 9.0 (or your version)
    Dim olApp As Outlook.Application
    Dim olMail As MailItem
    Dim c As Range
    
    For Each c In Range("L2:L" & Range("L65536").End(xlUp).Row)
    
'Do you want to change the formula to > 30
    If c - c.Offset(0, -1) >= 30 Then
    
        Set olApp = New Outlook.Application
        Set olMail = olApp.CreateItem(olMailItem)
                With olMail
'Change email address here **********************************
                    .To = "jim.boy@emailhere.com"
                    .Subject = Range("B" & c.Row).Value & " " & Range("C" & c.Row).Value
'Change name ****************
                    .Body = "Hello" & vbNewLine & vbNewLine & _
                            "Message here"
                    .Send  'Or use Display
                Set olMail = Nothing
        End With
        Set olApp = Nothing
        Application.ScreenUpdating = True
End If
Next c
End Sub

Morning,

How do I do this on Excel 2010, I can find the tools tab. I have the same request basically, if the value in a cell is equal or less than 30 days, I need to send the e-mail automatically, always to the same adress. I have been struggling for a while now, and posted threat on the group but can't seem to get an answer or in fact a solution.

I'm still learning and trying to anderstand the above, but I'm as lost as a flea on a cat.

Please assist
 
Upvote 0

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,216,073
Messages
6,128,634
Members
449,460
Latest member
jgharbawi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top