Macro to send mail through Outlook
Sub Outlook_Basic()
'Variable to create Outlook. Used reference MS Outlook library.
Dim OApp As Outlook.Application
Dim OEmail As Outlook.MailItem
'Intialization of outlook
Set OApp = New Outlook.Application
'Setting new mail
Set OEmail = Outlook.CreateItem(olMailItem)
'Action with the mail
With OEmail
.Display
.To = "kvinay.g@gmail.com"
.CC = "kvinay.g@gmail.com"
.Body = "Hi All, This is a test Outlook mail. "
.Subject = "Test Mail"
.Attachments.Add (Environ("UserProfile") & "\desktop\test.xlsm")
.Send
End With
MsgBox "Done!"
End Sub
No comments:
Post a Comment