Tommy Snoberg Soderberg
New Member
- Joined
- Mar 3, 2021
- Messages
- 17
- Office Version
- 365
- Platform
- Windows
Hi,
I have this macro to mail individual mail to my recipients with attachment. I have not altered this macro and it have worked up til now. I cannot find any error in my mail-addresses either. Any suggestions what to look for?
I have this macro to mail individual mail to my recipients with attachment. I have not altered this macro and it have worked up til now. I cannot find any error in my mail-addresses either. Any suggestions what to look for?
VBA Code:
Sub Email_From_Excel_Attachments()
Dim emailApplication As Object, emailItem As Object
Dim cell As Range, rng As Range
On Error GoTo myerror
Set emailApplication = CreateObject("Outlook.Application")
With Sheets("Adresses")
lastrow = .Cells(.Rows.Count, "B").End(xlUp).Row - 1
Set rng = .Cells(2, 2).Resize(lastrow, 1)
End With
For Each cell In rng.Cells
Set emailItem = emailApplication.CreateItem(0)
With emailItem
.To = cell.Value
.cc = cell.Offset(, 1).Value
.Subject = cell.Offset(, 2).Value & Date
.Body = cell.Offset(, 3).Value
.Attachments.Add cell.Offset(, 4).Value
.Send
End With
Set emailItem = Nothing
Next cell
myerror:
If Err <> 0 Then MsgBox (Error(Err)), 48, "Error"
End Sub