SteelheadBen
New Member
- Joined
- Jun 26, 2022
- Messages
- 1
- Office Version
- 365
- Platform
- Windows
Greetings,
I have this set up perfectly, except it opens all the rows in many separate emails. I want this module to only make 1 email containing the latest cell information in the last row in the spreadsheet and send one email containing the last row information. Can anyone help? I used a template to create this, so there may be unnecessary information in this code.
Thank you for your time in helping me with this!
I have this set up perfectly, except it opens all the rows in many separate emails. I want this module to only make 1 email containing the latest cell information in the last row in the spreadsheet and send one email containing the last row information. Can anyone help? I used a template to create this, so there may be unnecessary information in this code.
Thank you for your time in helping me with this!
VBA Code:
Sub sendCustEmails()
Dim objOutlook As Object
Set objOutlook = CreateObject("Outlook.Application")
Dim objEmail As Object
Application.EnableEvents = True
intRow = 2
strClientID = ThisWorkbook.Sheets("Sheet2").Range("A" & intRow).Text
While (strClientID <> "")
Set objEmail = objOutlook.CreateItem(olMailItem)
strMailSubject = ThisWorkbook.Sheets("Sheet2").Range("A2").Text
strMailBody = ThisWorkbook.Sheets("Sheet2").Range("A2").Text
strMonth = ThisWorkbook.Sheets("Sheet2").Range("C2").Text
strSO = ThisWorkbook.Sheets("Sheet2").Range("A" & intRow).Text
strCustomerName = ThisWorkbook.Sheets("Sheet2").Range("B" & intRow).Text
strDueDate = ThisWorkbook.Sheets("Sheet2").Range("C" & intRow).Text
strDueStatus = ThisWorkbook.Sheets("Sheet2").Range("D" & intRow).Text
strCreationDate = ThisWorkbook.Sheets("Sheet2").Range("E" & intRow).Text
strCompletionDate = ThisWorkbook.Sheets("Sheet2").Range("F" & intRow).Text
strOrderStatus = ThisWorkbook.Sheets("Sheet2").Range("G" & intRow).Text
strBoxSize = ThisWorkbook.Sheets("Sheet2").Range("H" & intRow).Text
strWeight = ThisWorkbook.Sheets("Sheet2").Range("I" & intRow).Text
With objEmail
.To = "WILL FILL OUT LATER"
.CC = "WILL FILL OUT LATER"
.Subject = "order # " & strMailSubject & " is Complete"
.Body = "Team," & vbNewLine & vbNewLine & "This email is to notify that order " & strSO & " for " & strCustomerName
& " is complete and ready for shipment. Box and weight information is provided below."
& vbNewLine & vbNewLine & "Box Size: " & strBoxSize & vbNewLine & "Weight: "
& strWeight & vbNewLine & vbNewLine
& "For any additional information about this order, please contact me"
& vbNewLine & vbNewLine & "Thanks," & vbNewLine & vbNewLine & "Shipping Department"
.Display
End With
intRow = intRow + 1
strClientID = ThisWorkbook.Sheets("Sheet2").Range("A" & intRow).Text
Wend
MsgBox "Done"
End Sub