Please could someone help me as i'm new to vba.
in my spreadsheet A1, A2, A3 & A4 i have got some jpeg file addresses. I need to alter the code below to attach all 4 addresses into an outlook email. If there are less than 4 I still need it attach those. e.g if there is only 1 address in A1 then I still need it to attach that.
Sub SendMail()
Dim oOutlook As Object
Dim oMailItem As Object
Dim oRecipient As Object
Dim oNameSpace As Object
Dim emailDate As Date
Dim sAttachment As String
sAttachment = Range("A1")
Set oOutlook = CreateObject("Outlook.Application")
Set oMailItem = oOutlook.CreateItem(0)
With oMailItem
Set oRecipient = .Recipients.Add("email address")
oRecipient.Type = 1 '1 = To, use 2 for cc
'keep repeating these lines with
'your names, adding to the collection.
.Subject = "Data for " & Format(emailDate, "dd mmm yyyyy")
.Body = "This is data for " & Format(emailDate, "dd mmm yyyyy")
.Attachments.Add sAttachment
.Display
End With
End Sub
Bookmarks