Hi
The correct code is
Sub SendEMail()
Dim OLApp As Outlook.Application
Dim OLEMail As Outlook.MailItem
Dim Adressbook As Worksheet, MailTo As String, Code As String, Counter As Integer, LR As Integer, Path As String
'
Set OLApp = New Outlook.Application
Set Adressbook = ThisWorkbook.Worksheets("Adress Book")
LR = Adressbook.Cells(Rows.Count, "A").End(xlUp).Row
'
For Counter = 2 To LR
' Initialise Object Mail here
Set OLEMail = OLApp.CreateItem(olMailItem)
'
MailTo = Adressbook.Cells(Counter, "C").Value
Code = Adressbook.Cells(Counter, "A").Value
Path = "C:\Users\J\Desktop\Send Dispatch Details\Attachments\" & Code & ".xlsm"
If MailTo <> "" Or MailTo = Null Then
'On Error GoTo Jumper
With OLEMail
.Display
.BodyFormat = olFormatPlain
.To = MailTo
.Subject = "ZFI/" & Code & " - Dispatch Details"
.Attachments.Add Path
.Send
End With
End If
' Release object
Set OLEMail = Nothing
'Jumper:
Next Counter
' Release other object
Set OLApp = Nothing
Set Adressbook = Nothing
'
MsgBox "Dispatch Details E-Mailed!", vbOKOnly, "E-Mail"
End Sub
A+
Bookmarks