I am trying to send a separate email to each individual in a pivot table but also use a different column to populate the subject line. So essentially have email and topic in a pivot table. The email should be sent to each email address and use the topic for that email address to populate the subject line. This is working with the exception that it is creating everything twice likely due to my range. How can I get this to only send once?
VBA Code:
Sub Email()
Dim i As Integer, n As Integer, Mail_Object, Email_Subject, o As Variant, lr As Long
lr = Cells(Rows.Count, "A").End(xlUp).Row
lra = Cells(Rows.Count, "B").End(xlUp).Row
Set Mail_Object = CreateObject("Outlook.Application")
For i = 7 To lr
For n = 7 To lra
With Mail_Object.CreateItem(o)
.Subject = Range("B" & n).Value
.To = Range("A" & i).Value
.Body = Range("B2").Value
'.Send
.display 'disable display and enable send to send automatically
End With
Next n
Next i
MsgBox "E-mail successfully sent", 64
Application.DisplayAlerts = False
Set Mail_Object = Nothing
End Sub