Link to home
Create AccountLog in
Avatar of desmondwkng
desmondwkngFlag 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
Avatar of Chris Bottomley
Chris Bottomley
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account

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

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 = ","
        If str <> "" Then .To = .To & "," & str
    End With
End Sub

Open in new window


Note replacing .display with .send will simply send the email ... if that is required in the application.