[Solved] Email via macro

Can i create a email form to be filed by macro for monthly
Hello Asalhaljayar

Welcome to ExcelDemy Forum. Thanks for reaching out and posting your question. You want to create an email form to be filled out dynamically by a macro for the current month.

I am delighted to inform you that I have developed an Excel VBA sub-procedure to fulfil your requirements.

Follow these steps:

Step 1: Navigate to the Developer tab => Click on Visual Basic to open the VBA Editor.
Navigate to Developer tab and click on Visual Basic.png

Step 2: Hover over Insert => Click on Module => Paste the following code in the module => You will see the Run command above the module like the image below.
Code:
Sub SendEmailWithDynamicSubject()

    Dim OutApp As Object
    Dim OutMail As Object
    Dim MailBody As String
    Dim SubjectText As String

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

    SubjectText = "Report: " & Format(Now, "mmmm yyyy")

    OutMail.To = "[email protected]"
    OutMail.Subject = SubjectText
   
    MailBody = "Dear Shovon," & vbCrLf & vbCrLf & _
               "Attached is the monthly report for your review." & vbCrLf & vbCrLf & _
               "Sincerely," & vbCrLf & _
               "Lutfor"

    OutMail.Body = MailBody

    OutMail.Display

    Set OutMail = Nothing
    Set OutApp = Nothing

End Sub
Hover over Insert, click on Module and paste the following code in the module.png

Step 3: Click on Run to see the output like the following GIF.
Output of running Excel VBA Code.gif

I have attached the solution workbook for better understanding. Good luck!

Regards
Lutfor Rahman Shimanto
 

Attachments

  • Asalhaljayar (SOLVED).xlsm
    14.8 KB · Views: 1

Online statistics

Members online
1
Guests online
27
Total visitors
28

Forum statistics

Threads
292
Messages
1,268
Members
531
Latest member
lonkfps
Top