Avatar of desmondwkng
desmondwkng
Flag for Hong Kong asked on

Excel VBA - Email

How Can I write a VBA and email the current file to different people and hard some of the message, and some variables (including the topic) with message box
Microsoft ExcelMicrosoft OfficeMicrosoft Applications

Avatar of undefined
Last Comment
Chris Bottomley

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Chris Bottomley

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SmittyPro

See: www.rondebruin.nl/sendmail.html

He's got all the Outlook code examples you'll ever need.

HTH,
Chris Bottomley

The same thing from a different application is as follows:

Sub sendamail()
Dim str As String
Dim olkApp As Object

    str = InputBox("Identify any extra recipients", "Recipient Entry")
    Set olkApp = CreateObject("outlook.application")
    With olkApp.CreateItem(0)
        .Subject = "My Subject"
        .Body = "Mail Body" & vbCrLf & vbCrLf & "And it all starts here"
        .To = "fred@fred.com, doris@doris.com"
        If str <> "" Then .To = .To & "," & str
        .Display
    End With
    
End Sub

Open in new window


Chris

Note replacing .display with .send will simply send the email ... if that is required in the application.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck