Results 1 to 5 of 5

VBA code to send emails if column i = >5

Threaded View

  1. #1
    Registered User
    Join Date
    08-03-2023
    Location
    berkshire
    MS-Off Ver
    365
    Posts
    2

    VBA code to send emails if column i = >5

    Below is the code i use i need a check to see if column i is greater than 5, if it is then send the email if not do not send the email


    Sub Send_Bulk_Mails()
    Dim sh As Worksheet
    Set sh = ThisWorkbook.Sheets("sheet1")
    Dim i As Integer
    
    Dim OA As Object
    Dim msg As Object
    
    Set OA = CreateObject("outlook.application")
    
    Dim last_row As Integer
    last_row = Application.CountA(sh.Range("c:c"))
    
    For i = 2 To last_row
    Set msg = OA.createitem(0)
    msg.to = sh.Range("i" & i).Value
    msg.cc = sh.Range("j" & i).Value & ";" & sh.Range("k" & i).Value
    msg.Subject = sh.Range("l" & i).Value
    msg.Body = sh.Range("m" & i).Value
    
    msg.send
    
    sh.Range("n" & i).Value = "1"
    
    Next i
    
    MsgBox "All emails have been sent"
    
    End Sub
    Last edited by AliGW; 08-03-2023 at 07:48 AM. Reason: Code tags added - please review the forum rules.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA Code Automatically send emails, but emails don't show up in sent box
    By AndrewK02 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-14-2022, 02:05 PM
  2. Send 2 separate/different emails using 1 VBA code?
    By rachelr1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-22-2020, 05:57 AM
  3. Tweak to existing VBA code to send emails on Mac
    By mrbusto71 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-28-2018, 06:30 PM
  4. Use of CDO code to send emails failing
    By DEB1000 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-29-2015, 03:49 PM
  5. Help with code to send automatic emails
    By hauckj14 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-16-2015, 12:45 PM
  6. Any Excel code to send emails automatically
    By knighty2002uk in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-01-2014, 05:55 AM
  7. VB Code to send emails depending on cell value
    By yorilla in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-26-2012, 11:14 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1