So I have an excel sheet organized by case that are assigned to emails. Each case is assigned to one email and each email is responsible for more than one case. Emails are not in order, they are scattered throughout the column. I want to create an automated email that sends a reminder every Monday (this I havent figured out how yet) to submit the case. Problem is I want to send one email per person regrouping all the cases assigned to them that are due. (When a case is closed it disappears from the sheet so no need to worry about this).
Here's what I already wrote:
Sub datesexcelvba()
Dim myApp As Outlook.Application, mymail As Outlook.MailItem
Dim mydate1 As Date
Dim mydate2 As Long
Dim datetoday1 As Date
Dim datetoday2 As Long
Dim engineer As Range
Dim x As Long
lastrow = Sheets("Messages english").Cells(Rows.Count, 1).End(xlUp).Row
For x = 2 To lastrow
mydate1 = Cells(x, 3).Value
mydate2 = mydate1
Cells(x, 7) = mydate2
datetoday1 = Date
datetoday2 = datetoday1
Cells(x, 9).Value = datetoday2
Set daysLeft = mydate2 - datetoday2
Function itsokay()
If daysLeft <= 14 And daysLeft >= 8 Then
Set myApp = New Outlook.Application
Set mymail = myApp.CreateItem(olMailItem)
mymail.To = Cells(x, 2).Value
'.send
With mymail
.Subject = (xx)
.Body = (Message) (content of a cell) (message)...etc
.Display
End With
Cells(x, 10) = Date
Cells(x, 10).Interior.ColorIndex = 3
Cells(x, 10).Font.ColorIndex = 2
Cells(x, 10).Font.Bold = True
End If
End Function
Function comeon()
If daysLeft <= 7 And daysLeft >= 4 Then
Set myApp = New Outlook.Application
Set mymail = myApp.CreateItem(olMailItem)
mymail.To = Cells(x, 2).Value
'.send
With mymail
.Subject = (xx)
.Body = (Message) (content of a cell) (message)...etc
.Display
End With
Cells(x, 11) = Date
Cells(x, 11).Interior.ColorIndex = 3
Cells(x, 11).Font.ColorIndex = 2
Cells(x, 11).Font.Bold = True
End If
End Function
Function late()
If daysLeft < 4 Then
Set myApp = New Outlook.Application
Set mymail = myApp.CreateItem(olMailItem)
mymail.To = Cells(x, 2).Value
'.send
With mymail
.Subject = (xx)
.Body = (Message) (content of a cell) (message)...etc
.Display
End With
Cells(x, 12) = Date
Cells(x, 12).Interior.ColorIndex = 3
Cells(x, 12).Font.ColorIndex = 2
Cells(x, 12).Font.Bold = True
End If
End Function
engineer = Cell(x, 6).Value
If engineer = "PLM" Then
// here i should write the code that sends each email(functions created above to the engineer)
Next
Set myApp = Nothing
Set mymail = Nothing
End Function
Thank you !! One last question: How can i show the info in a cell in between text in the .Body function??This is what my excel sheet looks like The email has to be sent only when status is design, and the text of the email roughly look like this Dear (F2), This is a reminder that your dcp (A2) (b2) is due on the (G2), your Dcp (a3) (b3) is due on the (g3) error 13 screenshot