VB to Send File as Attachment

keith

Board Regular
Joined
Mar 3, 2002
Messages
88
Does anyone know if there is a way to create a macro to send the current workbook as an attachement to predetermined receipients? I try to record a macro so I can view the code BUT mailto: automatically addresses the "to" email field but doesn't pick up the attachement and "file"-"sendto"-"mail as attachement" picks up the attachment but doesn't address the "to" field. I need a macro that does it all automatically with the user just clicking a button..
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Hi Keith,

This code attaches the workbook containing the code to three recipients:

Dim RecipVal As Variant

RecipVal := Array("friend1@aol.com","friend2@hotmail.com","friend3@yahoo.com")

ThisWorkbook.SendMail Recipients:=RecipVal, _
Subject:="Email Test"
 
Upvote 0
WHOO HOO! I haven't tried the code yet but I am glad someone posted. No one responded for so long that I went to the next project..

i guess there really are people that look at messages past the first page of posts...!

Thank you , thank you, thank you!
 
Upvote 0
I had to take out the : in

RecipVal := Array

and change it to just

RecipVal = Array

And it works like a dream...

.SendMail is one to remember... Thanks
 
Upvote 0
Re: VB to Send File as Attachment (for Word documents)

How do I save a word document before sending it as an attachment using VBA? Here is my current code. All data that was filled into the form is erased after I hit run the macro :(. Please help!!!

Private Sub Submit_Click()
Set Destwb = ActiveDocument
' Pop up Macro / Attestation confirm
If Counter Mod 1 = 0 Then
If MsgBox("I attest to having answered all the questions and to having filled out the form accurately.", vbYesNo) = vbNo Then End
End If

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
With OutMail
.to = ""
.CC = ""
.BCC = ""
.Subject = "Document"
.Body =
.Attachments.Add Destwb.FullName
.Display 'or use .Send
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,652
Messages
6,120,746
Members
448,989
Latest member
mariah3

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