I'm attempting to modify some previous code I wrote which would send out an email to the email address listed in the column next to the specified value. The value was "EXPIRED", however, what I'm trying to do now is basically send out one email within the active report without sending multiple emails based on number of records, and not unique store number. Store number may be duplicated based on how much inventory is in a negative status. Store number is located in Column A and email address is located in Column 31. As I stated before I would like to attach a copy of the report so all Managers can see how much inventory is in negative status, but only send one email regardless of how many records they have. Here's the code I've modified, but the line of code that I'm unsure as to how to modify is:
Line of code:
Here's the full code:
Any and all help is greatly appreciated.
D.
Line of code:
Rich (BB code):
If MailDest = "" And Cells(iCounter, 1).Offset(0, -30) = "EXPIRED" Then
Here's the full code:
Rich (BB code):
Sub OutlookEmail()
Dim OutLookApp As Object
Dim OutLookMailItem As Object
Dim iCounter As Integer
Dim MailDest As String
Dim MailDest2 As String
Set OutLookApp = CreateObject("Outlook.application")
Set OutLookMailItem = OutLookApp.CreateItem(0)
Worksheets("Sheet1").Activate
For iCounter = 2 To WorksheetFunction.CountA(Columns(31))
MailDest = ""
If Len(Cells(iCounter, 1).Offset(0, -0)) > 0 Then
If MailDest = "" And Cells(iCounter, 1).Offset(0, -30) = "EXPIRED" Then
Set OutLookMailItem = OutLookApp.CreateItem(0)
With OutLookMailItem
MailDest = Cells(iCounter, 31).Value
'MailDest2 = Cells(iCounter, 31).Value
.To = MailDest
.CC = "email1@somedomain.com"; "email2@somedomain.com"; "email2@somedomain.com"
'.BCC = "email4@somedomain.com"
.Subject = "Subject"
.HTMLBody = "Hello" & MailDest & "," _
& "Email body here..."
'.Display
.Send
End With
End If
End If
Next iCounter
Set OutLookMailItem = Nothing
Set OutLookApp = Nothing
End Sub
End Sub
D.
Last edited by a moderator: