VBAn00bheh
New Member
- Joined
- Jul 8, 2019
- Messages
- 1
Hi All,
This is my current code:
Each row is a separate email with different recipients and attachments. If I run the macro, it runs everything. How do I make it run ONLY IF Column A contains my own email address? Like if it's blank, the window for that shouldn't appear in Outlook.
Thank you so much! I appreciate your help.
This is my current code:
Code:
'binding
Sub bulk_email()
On Error Resume Next
Dim o As Outlook.Application
Set o = New Outlook.Application
Dim omail As Outlook.MailItem
Dim Signature As String
Dim i As Long
For i = 2 To Range("A10000").End(xlUp).Row
Set omail = o.CreateItem(olMailItem)
emailString = "<font size=""2"" face=""Verdana"" color=""black"">" & Cells(i, 5).Value & "<br>" & "<br>" _
& Cells(i, 6).Value & "<br>" & "<br>" _
& Cells(i, 7).Value & "<br>" & "<br>" _
& Cells(i, 8).Value & "<br>" & Cells(i, 9).Value & "</font>"
With omail
.Display
.Sender = Cells(i, 1).Value
.To = Cells(i, 2).Value
.CC = Cells(i, 3).Value
.Subject = Cells(i, 4).Value
.HTMLBody = emailString & .HTMLBody
.Attachments.Add Cells(i, 10).Value
.Attachments.Add Cells(i, 11).Value
.Attachments.Add Cells(i, 12).Value
.Attachments.Add Cells(i, 13).Value
.Attachments.Add Cells(i, 14).Value
.Attachments.Add Cells(i, 15).Value
.Display
End With
Next
End Sub
Each row is a separate email with different recipients and attachments. If I run the macro, it runs everything. How do I make it run ONLY IF Column A contains my own email address? Like if it's blank, the window for that shouldn't appear in Outlook.
Thank you so much! I appreciate your help.