Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
General mail failure when sending e-mail from Excel | Excel Discussion (Misc queries) | |||
Sending E-mail | Excel Programming | |||
Sending E-mail | Excel Worksheet Functions | |||
Help sending mail... | Excel Programming |