Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Sending mail

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 ,
", Subject:="Filename"

End Sub

--
Tomas S
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Sending mail

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.


"Tomas Stroem" wrote:

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 ,
", Subject:="Filename"

End Sub

--
Tomas S

  #3   Report Post  
Posted to microsoft.public.excel.programming
Member
 
Location: In a hole in the ground there lived Joshua Fandango
Posts: 30
Default Sending mail

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 = "
.CC = "
.BCC = "
.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
----------------------------------------------------------------

HtH,
JF



On 10 Dec, 07:26, Tomas Stroem
wrote:
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 ,
", Subject:="Filename"

End Sub

--
Tomas S


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Sending mail

Joshua,

This works great for me to, Many thanks !!
--
Tomas S


"Joshua Fandango" wrote:

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 = "
.CC = "
.BCC = "
.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
----------------------------------------------------------------

HtH,
JF



On 10 Dec, 07:26, Tomas Stroem
wrote:
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 ,
", Subject:="Filename"

End Sub

--
Tomas S



  #5   Report Post  
Posted to microsoft.public.excel.programming
Member
 
Location: In a hole in the ground there lived Joshua Fandango
Posts: 30
Default Sending mail

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

Ooops! :)

On 10 Dec, 12:16, Tomas Stroem
wrote:
Joshua,

This works great for me to, Many thanks !!
--
Tomas S



"Joshua Fandango" wrote:
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 = "
* * .CC = "
* * .BCC = "
* * .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
----------------------------------------------------------------


HtH,
JF


On 10 Dec, 07:26, Tomas Stroem
wrote:
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 ,
", Subject:="Filename"


End Sub


--
Tomas S- Hide quoted text -


- Show quoted text -




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Sending mail

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

Again Many Thanks
--
Tomas S


"Joshua Fandango" wrote:

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

Ooops! :)

On 10 Dec, 12:16, Tomas Stroem
wrote:
Joshua,

This works great for me to, Many thanks !!
--
Tomas S



"Joshua Fandango" wrote:
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 = "
.CC = "
.BCC = "
.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
----------------------------------------------------------------


HtH,
JF


On 10 Dec, 07:26, Tomas Stroem
wrote:
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 ,
", Subject:="Filename"


End Sub


--
Tomas S- Hide quoted text -


- Show quoted text -



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
General mail failure when sending e-mail from Excel Adrienne Excel Discussion (Misc queries) 5 November 4th 05 12:59 PM
Sending E-mail CB Hamlyn Excel Programming 5 July 24th 05 11:48 PM
Sending E-mail litew_8 Excel Worksheet Functions 1 November 21st 04 06:13 AM
Help sending mail... Bob Phillips[_6_] Excel Programming 1 August 12th 04 08:50 PM


All times are GMT +1. The time now is 02:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"