• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Send email (with VBA) and update "status"

Hello,

Good day!

Need helps in below;

I want to send multiple emails (via VBA) and simultaneously I want to update the status of email.
>In case, if email drafted but not sent, then status should be "Not Sent"
>In case, If email sent then status should be "Sent"


Please help, humble request from members and ninjas.

83522


Thanks and Regards
Mehmud
 

Attachments

  • Email Status.xlsb
    7.9 KB · Views: 2
Edit: Typo

Code:
Sub SendEmails()
    Dim lastRow As Long
    Dim OutApp As Object
    Dim OutMail As Object
    Dim strbody As String
    Dim i As Long

    Set OutApp = CreateObject("Outlook.Application")
  

    'How much data is there?
    lastRow = Cells(Rows.Count, "A").End(xlUp).Row
  
    'Prevent screen flicker
    Application.ScreenUpdating = False
  
    For i = 2 To lastRow
        If UCase(Cells(i, "E").Value) <> "SENT" Then
            Set OutMail = OutApp.CreateItem(0)
          
            With OutMail
                .to = Cells(i, "A").Value
                .cc = Cells(i, "B").Value
                .Subject = Cells(i, "C").Value
                .body = Cells(i, "D").Value
              
                Cells(i, "E").Value = "Sent"
              
                .send   'or use .Display
            End With
          
            Set OutMail = Nothing
        End If
    Next i
    Set OutApp = Nothing
    Application.ScreenUpdating = True
End Sub
 
Last edited:
Dear Luke and Marc,


Thanks for your supports and replies.

Your solution works.

All good, only 1 issue.

Let me explain you step by step;

step1.
I cleared the column "E" first.

Step2
I go to VBA then run the code

step 3
VBA trying to send the first email and Outlook was giving pop alert for 5 second

HERE, I Need help

1. At step 3, if I click on Allow then outlook will send the email and status on column E will be updated "Sent"

2. If I click on Deny then system gave me some error (refer below screenshot) but still email status is updated as "Sent"

83701

WHAT I NEED HELP FOR;

if I deny then system should update in column as "Not Sent"
In simple words, If email actually sent then only status should update else not.



I hope, I am able to explain.


Thanks and Regards,
-Khan
 
Back
Top