Run-Time Error 424

nuge725

New Member
Joined
Jun 16, 2011
Messages
21
Hello All,

Can someone please help me with this? I am trying to write the code to send Outlook emails from Excel. Ultimately, what I would like to do is have it automatically email 90 days before the date in the cell. However, I figured I would try this first to make sure that I have everything working properly...I'm just learning how to do this. Nevertheless, when I go to run the code below, I get a "Run-Time Error 424: Object Required" message for this line:
Code:
TrainingDate = Format(cell.Offset(0, 1).Value.["mm/dd/yy"])

Any help that can be given would be greatly appreciated. Also, if you either see any other errors, or know how to set this up to send on a certain date, that advice is welcome as well. Please let me know if you need more information, and thanks in advance.

Ryan

Code:
Sub SendEmail()
    Dim OutlookApp As Outlook.Application
    Dim MItem As Outlook.MailItem
    Dim cell As Range
    Dim Subj As String
    Dim EmailAddr As String
    Dim Recipient As String
    
    Set OutlookApp = New Outlook.Application
    
    For Each cell In Columns("B").Cells.SpecialCells(xlCellTypeConstants)
        If cell.Value Like "*@*" Then
            Subj = "Training Dates"
            Recipient = cell.Offset(0, -1).Value
            EmailAddr = cell.Value
            TrainingDate = Format(cell.Offset(0, 1).Value.["mm/dd/yy"])
            
            Msg = "Dear" & Recipient & vbCrLf & vbCrLf
            Msg = Msg & "Your TRAINING TYPE training is due on:"
            Msg = Msg & TrainingDate & vbCrLf & vbCrLf
            Msg = Msg & "NAME" & vbCrLf
            Msg = Msg & "TITLE"
            
            Set MItem = OutlookApp.CreateItem(olMailItem)
            With MItem
                .To = EmailAddr
                .Subject = Subj
                .Body = Msg
                .Send
            End With
        End If
    Next
End Sub
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
I don't know if this is the only problem but it should be like this

Code:
TrainingDate = Format(cell.Offset(0, 1).Value, "mm/dd/yy")
 
Upvote 0
VoG,

I tried that and I kept getting a "Compile Error: Expected: Identifier or Bracketed Expression" message, so I tried adding the brackets and that resolved that issue.
 
Upvote 0
Nevermind...that fixed it. I found the problem I had, which was delivering the Compile Error was that I had a period instead of comma. Thanks VoG!!!
 
Upvote 0

Forum statistics

Threads
1,203,675
Messages
6,056,683
Members
444,882
Latest member
cboyce44

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