Sub Alerta_email()
Dim meuoutlook As Outlook.Application
Dim criaremail As Outlook.MailItem
Range(“E14”).Activate
Do Until activateCell.Value = “”
If ActiveCell.Offset(0, 1).Value < Range(“F7”, ”G7”) Then
Set meuoutlook = New Application
Set criaremail = Outlook.CriateItem(olMailItem)
With criaremail
.BodyFormat = olFormatHTML
.Display
.HTMLBody = “Alerta automático” & “<br>” & “O documento: “ _
& ActiveCell.Offset (0,2).Value & “ vai expirar em “ _
& ActiveCell.Offset (0,4).Value & “ Dias. “
.To = Range(“n14”).Value
.cc = Range(“o14).Value
.subject = “Alerta de vencimento do documento: “ & ActiveCell.Offset (0,2).Value
.send
End With
End If
ActiveCell.offse(1, 0).Select
Loop
End Sub
Videos on YouTube sent me to References to select some boxes.
I left the following selected:
I've corrected some of the more obvious errors in your code, see below. I'm not quite sure what was your intended meaning of If ActiveCell.Offset(0, 1).Value < Range(“F7”, ”G7”) Then
. Anyway, what you need to do is to select the Microsoft Outlook Object Library:
Corrected code:
Sub Alerta_email()
Dim meuoutlook As Outlook.Application
Dim criaremail As Outlook.MailItem
Range("E14").Activate
Do Until ActiveCell.Value = ""
If ActiveCell.Offset(0, 1).Value < Range("F7").Value Or ActiveCell.Offset(0, 1).Value < Range("G7").Value Then
Set meuoutlook = New Outlook.Application
Set criaremail = meuoutlook.CreateItem(olMailItem)
With criaremail
.BodyFormat = olFormatHTML
.Display
.HTMLBody = "Alerta automático" & "<br>" & "O documento: " _
& ActiveCell.Offset(0, 2).Value & " vai expirar em " _
& ActiveCell.Offset(0, 4).Value & " Dias. "
.To = Range("N14").Value
.CC = Range("O14").Value
.Subject = "Alerta de vencimento do documento: " & ActiveCell.Offset(0, 2).Value
.Send
End With
End If
ActiveCell.Offset(1, 0).Select
Loop
End Sub