VBA code to show email sent status in coulmn

SRL

New Member
Joined
Sep 17, 2022
Messages
1
Office Version
  1. 365
Hi,

I need VBA code to show email sent status in one column of excel

please help me to add this code in my below mentioned existing code

1663397995017.png







Sub SendCustEmails()

Dim ObjOutlook As Object
Set ObjOutlook = CreateObject("Outlook.Application")
Dim ObjEmail As Object

intRow = 2
strEmployeeID = ThisWorkbook.Sheets("Employee Details").Range("A" & intRow).Text

While (strEmployeeID <> "")
Set ObjEmail = ObjOutlook.CreateItem(olMailItem)
strMailSubject = ThisWorkbook.Sheets("Mail Details").Range("A2").Text
strMailBody = ThisWorkbook.Sheets("Mail Details").Range("B2").Text
strMonth = ThisWorkbook.Sheets("Mail Details").Range("C2").Text

strFolder = "D:\Payslip\AUG 2022\QG\A\PAYSLIP"
strEmployeeID = ThisWorkbook.Sheets("Employee Details").Range("A" & intRow).Text
strEmployeeName = ThisWorkbook.Sheets("Employee Details").Range("B" & intRow).Text
strEmailID = ThisWorkbook.Sheets("Employee Details").Range("C" & intRow).Text
strFileName = ThisWorkbook.Sheets("Employee Details").Range("D" & intRow).Text

strMailSubject = Replace(strMailSubject, "<Employee ID>", strEmployeeID)
strMailBody = Replace(strMailBody, "<Employee Name>", strEmployeeName)
strMailBody = Replace(strMailBody, "<Month>", strMonth)

With ObjEmail
.To = CStr(strEmailID)
.Subject = strMailSubject
.Body = strMailBody
.Attachments.Add strFolder & "\" & strFileName
.Send
End With
intRow = intRow + 1
strEmployeeID = ThisWorkbook.Sheets("Employee Details").Range("A" & intRow).Text
Wend
MsgBox "Emails Sending Completed"
End Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Try this:

After the
VBA Code:
End With
(assuming that D column is where the Email Status is), put:
VBA Code:
 ThisWorkbook.Sheets("Mail Details").Range("D"& intRow)="Sent"
 
Upvote 0

Forum statistics

Threads
1,216,082
Messages
6,128,716
Members
449,464
Latest member
againofsoul

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