VBA Macro Code To Send Email From Excel

Опубликовано: 29 Октябрь 2024
на канале: Learn Excel VBA
3,318
27

In this video, you will learn how you can use VBA Macro Code To Send Email From Excel.

---------------
Video Gears:
Mic used for Audio recording: https://amzn.to/32ZSagv
Soundproofing Foam that I use, this also helps to reduce echo: https://amzn.to/2Dy939l
For Video editing, I use Canva.com, you can join Canva by clicking here: https://www.canva.com/join/brake-euro...
Computer used for Editing: https://amzn.to/3bv9PjL
Mobile used for video shooting: https://amzn.to/3gZP00X
Reach out to me on Fiver for any excel automation projects: https://www.fiverr.com/share/71GKke
------------------

Below is the code used in the model:
Sub Send_Email_From_Excel()

Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

With OutMail
.to = "[email protected]"
.Subject = "Test1"
.Body = "Hello, This is Test Email."
.attachments.Add ActiveWorkbook.FullName
.display 'Write ".send" for sending emails
End With

Set OutMail = Nothing
Set OutApp = Nothing

End Sub
--------------------------------

Sub Send_Email_Dynamic_Inputs()

Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

With OutMail
.to = Range("C4").Value
.cc = Range("C5").Value
.Subject = Range("C6").Value
.Body = Range("C7").Value
'.attachments.Add ActiveWorkbook.FullName
'.attachments.Add ("C:\Temp\TrainingDemo.CSV")
.attachments.Add Range("C8").Value
.display
End With

Set OutMail = Nothing
Set OutApp = Nothing

End Sub