Send email in loop

jaeremata

New Member
Joined
Jan 20, 2021
Messages
24
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Hi. Good day. I need some help regarding my code. It's not doing the loop, I need to send email via excel that will do the loop but it's not working. I hope someone can help me fix my code. I know I'm missing something but I don't know where is it.


VBA Code:
  Sub Mail_Send()
    Dim OutApp As Object
    Dim OutMail As Object
  
    On Error GoTo cleanup
    Set OutApp = CreateObject("Outlook.Application")
  
 
  

 
    lr = Sheets("Sheet2").Cells(1048576, "F").End(xlUp).Row
  
    For x = 2 To lr
          
  
    If Sheets("Sheet2").Range("F" & x).Value = "No" Then
  
  
        vendorName = Sheets("Sheet2").Range("B" & x).Value
        supplier = Sheets("Sheet2").Range("C" & x).Value
        lead = Sheets("Sheet2").Range("D" & x).Value
        director = Sheets("Sheet2").Range("E" & x).Value
        Version = Sheets("Sheet2").Range("G" & x).Value
      
        HTMLBody = " <!Doctype html>" & _
"<html><head></head><body><div> Dear " & vendorName & ",</div><br><div><p> As a part of standard work, it is noticed you are using version " & Version & _
" of S-QIP and it is not refreshed with latest scorecard/NC details and associated responses from you.</p><p> Your regular refresh will allow Company to collaborate with you better in improving our product quality. Request to update it and intimate your stakeholders at the earliest.</p>" & _
" <p> If applicable, you are requested to update your S-QIP ver 5.8 as per the guidelines</p><p> Please reach out to respective SQE " & lead & "@gmail.com if you have any help or support.</p><p> Thanks, <br/> SQIP project Team</p></div></body></html>"
      
  
    With OutMail
    .To = vendorName
    .CC = lead & "@gmail.com;" & director & "@gmail.com"
    .BCC = ""
    .Subject = "SQIP Refresh " & vendorName
    .HTMLBody = HTMLBody
    .Display
    '.Send
  
    End With
  
 
  
    Sheets("Sheet2").Range("H" & x).Value = "Sent"
  
    End If
  
  
    Sheets("Sheet2").Range("H" & x).Value = "Nothing"
 
 
 
    Next x
  

            
 
    End Sub
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Forum statistics

Threads
1,214,923
Messages
6,122,283
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top