Link to home
Start Free TrialLog 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
ASKER CERTIFIED SOLUTION
Avatar of Chris Bottomley
Chris Bottomley
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
See: www.rondebruin.nl/sendmail.html

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

HTH,
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.