link to e-mail address

magdalene

New Member
Joined
Sep 13, 2006
Messages
5
how can i put a command button on a spreadsheet and when i click on the button it will automatically sent the sheet to an e-mail address
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Maybe you can adapt this


Code:
Sub Mail()

ActiveWorkbook.Save
'You must add a reference to the Microsoft outlook Library
     Dim OutApp As Object
    Dim OutMail As Object
    Dim strbody As String
    Dim Mail As Variant

Mail = MsgBox("Click OK to automatically email this workbook", vbInformation + vbOKCancel)
If Mail = vbCancel Then
Exit Sub
End If


    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
    strbody = Application.InputBox("Would you like to enter a message as part of the email?", "Email message", Type:=2)
 
    With OutMail
        .To = "Enter in email address"
        .CC = ""
        .BCC = ""
        .Subject = "Enter in title" & Date
        .Body = strbody
        .Attachments.Add ActiveWorkbook.FullName
        On Error Resume Next
        .Send   'or use .Display
        If Err > 0 Then MsgBox "You clicked 'No' - Therefore the email was not sent"
    End With

    Set OutMail = Nothing
    Set OutApp = Nothing
    MsgBox "Providing you clicked Yes, this email will appear in your Sent Box in Outlook"
    ActiveWorkbook.Save
    ActiveWorkbook.Close
 
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,232
Messages
6,123,763
Members
449,120
Latest member
Aa2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top