Sending mail

T

Tomas Stroem

I want to send a file to multiple persons by using a macro that runs each
time the file is saved. It works perfectly well with one person, but not when
I try to add more names. What is the correct syntax to do this? Code added
below

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
ActiveWorkbook.SendMail Recipients:="(e-mail address removed) ,
(e-mail address removed)", Subject:="Filename"

End Sub
 
F

Franz E

Online help says:
- for one recipient you need to use text, exactly as you do
- for more than one recipient you need to use a matrix with text strings.
 
J

Joshua Fandango

Hi Tomas,

The following works great for me.
Have it in a standard module & call it from the Before Save event.

Sub Email_This_Wbk()
Dim OutApp As Object
Dim OutMail As Object

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
.To = "(e-mail address removed)"
.CC = "(e-mail address removed);[email protected]"
.BCC = "(e-mail address removed)"
.Subject = "This week's reports"
.Body = "What ever you want"
.Attachments.Add ActiveWorkbook.FullName
.display
End With
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing
End Sub
 
J

Joshua Fandango

Just noticed... in the With OutMail change ".display" to ".send" to
have it actually send

Ooops! :)
 
T

Tomas Stroem

Will change this to make it exactly as I want to have it run.

Again Many Thanks
 

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

Top