DarkDrag318
New Member
- Joined
- Feb 27, 2025
- Messages
- 3
- Office Version
- 365
- 2024
- 2021
- 2019
- Platform
- Windows
Hello,
How can I add a condition to only create an email when the value is less or equal to 30? Also can it creating emails to start from row 3 and down instead of row 1?
Here is my macro code that I need help with, thank you:
Sub Create_Email()
Application.ScreenUpdating = False
Dim EmailTo As String
Dim EmailAddress As String
Dim Value As Double
Dim LastRow As Integer
Dim RowCounter As Integer
'Defining outlook variables
Dim OutApp As Object
Dim Outmail As Object
LastRow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row
For RowCounter = 2 To LastRow
EmailTo = Sheet1.Range("K" & RowCounter).Value
EmailAddress = Sheet1.Range("L" & RowCounter).Value
Value = Sheet1.Range("I" & RowCounter).Value
Name = Sheet1.Range("A" & RowCounter).Value
'Allocated and created
Set OutApp = CreateObject("Outlook.Application")
Set Outmail = OutApp.CreateItem(0)
With Outmail
.To = EmailAddress
.Subject = Name & ": " & "Loan Maturing in " & Value & " days"
.Body = "Dear " & EmailTo & _
vbNewLine & vbNewLine & _
"Please be advised that this account will be maturing. Proceed to obtain all required items begin to process an extension/renewal, if applicable." & _
vbNewLine & vbNewLine & _
"Kindly Regards," & _
vbNewLine & _
"Me"
'Set .SendUsingAccount = OutApp.Session.Accounts.Item("")
.display
'.Send
End With
Next RowCounter
Application.ScreenUpdating = True
End Sub
How can I add a condition to only create an email when the value is less or equal to 30? Also can it creating emails to start from row 3 and down instead of row 1?
Here is my macro code that I need help with, thank you:
Sub Create_Email()
Application.ScreenUpdating = False
Dim EmailTo As String
Dim EmailAddress As String
Dim Value As Double
Dim LastRow As Integer
Dim RowCounter As Integer
'Defining outlook variables
Dim OutApp As Object
Dim Outmail As Object
LastRow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row
For RowCounter = 2 To LastRow
EmailTo = Sheet1.Range("K" & RowCounter).Value
EmailAddress = Sheet1.Range("L" & RowCounter).Value
Value = Sheet1.Range("I" & RowCounter).Value
Name = Sheet1.Range("A" & RowCounter).Value
'Allocated and created
Set OutApp = CreateObject("Outlook.Application")
Set Outmail = OutApp.CreateItem(0)
With Outmail
.To = EmailAddress
.Subject = Name & ": " & "Loan Maturing in " & Value & " days"
.Body = "Dear " & EmailTo & _
vbNewLine & vbNewLine & _
"Please be advised that this account will be maturing. Proceed to obtain all required items begin to process an extension/renewal, if applicable." & _
vbNewLine & vbNewLine & _
"Kindly Regards," & _
vbNewLine & _
"Me"
'Set .SendUsingAccount = OutApp.Session.Accounts.Item("")
.display
'.Send
End With
Next RowCounter
Application.ScreenUpdating = True
End Sub