Sending e mail with attachment from button click

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have never used macros before..but i have created a button on excel
sheet...a CommandButton1 . Now when this button is clicked a blank e - mail
should open up with this spreadsheet attached to it...

Is there any way this is possible? What code is required for this?

Thanks
 
This code works for me:
Sub Mailit()
Dim BkName As String
ActiveWorkbook.Save
BkName = ActiveWorkbook.FullName
Dim Mailit As Object
Set Mailit = CreateObject("Outlook.Application")
Set NewMail = Mailit.CreateItem(olMailItem)
NewMail.Subject = ActiveWorkbook.Name
NewMail.Attachments.Add BkName
NewMail.Display
End Sub

Attach it to your button. If you want it available for any workbook, put the
module in your personal workbook. Also, be sure the reference to Microsoft
Visual Basic for Applications Extensibility (etc.) is checked under
Tools/Refereces in the VBE
 
On second thought , I had forgotten that Excel already provides w way to do
this without programming. Just Click File/Send To/ Mail Recipient(as
Attachment)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top