You should put
all your code here to see the objects you are using, maybe you are not using the right objects.
Or check the following example:
VBA Code:
Sub exampleemail()
Dim OutApp As Object, OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = "email@domain.com"
.Subject = "This is the Subject line"
If Range("G5").Value = "Specific Text" Then
.Attachments.Add "C:\trabajo\files\report.xlsx"
End If
'.Send
.Display
End With
End Sub
Try...
VBA Code:
.Attachments.Add "C:\Users\Documents\MadeUpFileLocation\ImageName.JPG"
Hope this helps!
Still can't seem to get it working. My full code is here (sensitive info omitted but all file names and locations have been double checked):
Sub Process1()
Dim App As Object, Itm As Object
Dim EmailSubject As String
Dim SendTo As String
Dim EmailBody As String
Dim ccTo As String
Dim i As Long
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Range("B2") = Date
Range("B3") = Time
For i = 5 To Range("B" & Rows.Count).End(3).Row
If Not IsEmpty(Range("B" & i).Value) Then
Set App = CreateObject("Outlook.Application")
Set Itm = App.createitem(0)
SendTo = Range("B" & i).Value
EmailSubject = Account Number- " & Range("C" & i).Value
EmailBody = Range("I3") & vbNewLine & vbNewLine & Range("I" & i).Value & Range("M" & i) & Range("H" & i).Value & Range("J" & i).Value & vbNewLine & Range("B1") & vbNewLine & Range("D1") & vbNewLine & Range("K" & i).Value
If Range("G" & i).Value = "1" Then
.Attachment.Add "C:\Users\UsernameOmitted\Documents\Image1.JPG"
.HTMLBody = "<img src=""cid:Image1.jpg"
End If
With Itm
.SentOnBehalfOfName = Range("L" & i).Value
.Subject = EmailSubject
.To = SendTo
.Body = EmailBody
.Send
End With
Set App = Nothing
Set Itm = Nothing
End If
Next
Application.ScreenUpdating = True
Application.DisplayAlerts = True
MsgBox "Process Complete", vbInformation
End Sub
Thank you for all of your help