Outlook Macro - Help Required


Joined
Sep 17, 2020
Messages
1
Reaction score
0
I need to send my attendance before I am close my outlook to specific Email address. Currently, I am using below coding. However, Email will save it in Out Box and out look will get closed. Next time when I re-open my out look, email will move to sent item.

Private Sub Application_Quit()


Dim obApp As Object
Dim NewMail As MailItem

Dim defaultColour As Long

Set obApp = Outlook.Application
Set NewMail = obApp.CreateItem(olMailItem)

'You can change the concrete info as per your needs
With NewMail
.Subject = "Logout Details - " & Now()
.To = "(e-mail address removed)"
.Body = "Hi All," & vbCrLf & vbCrLf & "I have logged out now " & vbCrLf & vbCrLf & "Thank you," & vbCrLf & "Ranjan"

Dim Answer As VbMsgBoxResult
Answer = MsgBox("Do you want to send Attendance Email.?", vbYesNo + vbCritical + vbFont24, "Attendance Email")


If Answer = vbYes Then
.Send

Set obApp = Nothing
Set NewMail = Nothing


End If

End With


End Sub
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top