Is there a way to set a reminder after sending e-mail?
I have VBA code that creates an e-mail and sets a reminder.
Sub RendaFixaAplicação()
Dim texto As String
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
texto = Range("J2").Value & ",insert some text here"
With OutMail
.Display
.to = Range("J3").Value
.CC = Range("J4").Value
.Subject = "Insert a subject here " & Range("E2").Value
.HTMLBody = texto & .HTMLBody
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
Call alerta1
End Sub
The reminder is made with the "Call alerta1" at the end of the code and is programmed like this:
Sub alerta1()
Dim objOutlookApp As Outlook.Application
Dim objTask As Outlook.TaskItem
Dim hora As String
Dim wd As WorksheetFunction
Set wd = Application.WorksheetFunction
Dim diautil As Date
diautil = wd.WorkDay(Date, 1)
If Time > "15:00:00" Then
hora = diautil & " 14:00:00"
Else
If Time < "14:00:00" Then
hora = Date & " 14:00:00"
Else
hora = Date & " 14:45:00"
End If
End If
Set objOutlookApp = CreateObject("Outlook.Application")
Set objTask = objOutlookApp.CreateItem(olTaskItem)
objTask.Subject = "Insert a Subject Here - " & Range("E2").Value
objTask.Display
objTask.body = "Cliente: " & Range("K2").Value & vbNewLine & "Email cliente: " & Range("J3").Value
objTask.ReminderSet = True
objTask.ReminderTime = hora
objTask.DueDate = hora
objTask.Close (olSave)
End Sub
It sets the reminder whether I send the e-mail or not.
I can't use .Send on the e-mail because there needs to be some editing in the e-mail.
Is there a way to make Excel wait for the e-mail to be sent then run the "alerta1"?