Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you program an Excel macro to email a file?

Status
Not open for further replies.

caillebotte

IS-IT--Management
Dec 8, 2002
22
US
Can you program an Excel macro to email a file (not the active worksheet)?
If so, can I see a simple coding example?
Thanks.
Caillebotte
 
When in Excel, press Alt + F11 and search for the " Sendmail method" in the " Help Menu".
You will find the necessary help there.

Good luck
 
Go take a look at the following site. Ron de Bruin has an excellent free addin called Sendmail that will do exactly that, and he also has loads of example code for you if you want to create your own:-


Regards
Ken...............
 
If you want it simpler than an Add-in:

Code:
Sub Send_Email()
' Be Sure to set a reference to MS Outlook before using this procedure.
' Go to Tools->References and select the Outlook library from the list and press OK.
Dim newOL As New outlook.Application
Dim newMail As MailItem
Set newOL = New outlook.Application
Set newMail = newOL.CreateItem(olMailItem)
With newMail
    .To = "noone@nowhere.com"
    .Subject = "This is a Test"
    .Body = "This is a test Email sent to you from Excel. " & _
        "Please, do not reply to this Email."
    .Attachments.Add Source:="EnterPath_And_FileName"
    .Display ' This will display the Email for editing
    ' .Send ' This will send the Email directly
End With
Set newMail = Nothing
Set newOL = Nothing
End Sub

I hope this helps!



Peace! [peace]

Mike

Never say Never!!!
Nothing is impossible!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top