Alphaboss7
New Member
- Joined
- Jul 31, 2017
- Messages
- 28
This line of code is not running:
within this code:
Any suggestions?
Code:
.Attachments.Add Range("I" & i).Value
within this code:
Code:
Sub CreateMail()
Dim objOutlook As Object
Dim objMail As Object
Dim i As Integer
Const olMailItem As Long = 0
Dim strbody As String
For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row '~~> Change to i = 2 if you have headings
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(olMailItem)
strbody = Range("K2") & " " & Range("A" & i) & "
" & "
" & _
Range("K3") & "
" & "
" & _
Range("K4") & " " & Range("B" & i).Value & "
" & _
Range("K5") & " " & Range("C" & i).Value & "
" & _
Range("K6") & " " & Range("K7") & "
" & "
" & _
Range("K8") & "
" & "
" & _
Range("K9") & "
" & "
" & _
Range("K10")
With objMail '~~> Chnage Below columns to suit your data, this was based off your example offsets
.To = Range("F" & i).Value
.cc = Range("G" & i).Value
.Subject = Range("J" & i).Value
.Attachments.Add Range("I" & i).Value '<-----This is the line that won't work
.HTMLBody = strbody '~~> You can change this to any range
.display
End With
Set objOutlook = Nothing
Set objMail = Nothing
Next i
End Sub
Any suggestions?