I want to send different files for different people with Gmail using excel.
Everything is well except when sending the attached items, it goes like this:
Person A receives File A
Person B receives File A and B
Person C receives File A, B, and C
it should be:
Person A receives File A
Person B receives File B
Person C receives File C
Here is my code:
List.Activate
With ActiveSheet
lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
For i = 2 To lastrow
With GMail
.Subject = List.Cells(i, 4).Value
.From = DB.Range("A20").Value
.To = List.Cells(i, 3).Value
.CC = DB.Range("A10").Value
.BCC = DB.Range("A12").Value
.TextBody = DB.Range("A14").Value
.AddAttachment (List.Cells(i, 1).Value)
End With
GMail.Send
Next i
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
Everything is well except when sending the attached items, it goes like this:
Person A receives File A
Person B receives File A and B
Person C receives File A, B, and C
it should be:
Person A receives File A
Person B receives File B
Person C receives File C
Here is my code:
List.Activate
With ActiveSheet
lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
For i = 2 To lastrow
With GMail
.Subject = List.Cells(i, 4).Value
.From = DB.Range("A20").Value
.To = List.Cells(i, 3).Value
.CC = DB.Range("A10").Value
.BCC = DB.Range("A12").Value
.TextBody = DB.Range("A14").Value
.AddAttachment (List.Cells(i, 1).Value)
End With
GMail.Send
Next i
With Application
.EnableEvents = True
.ScreenUpdating = True
End With