ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   send tomail all the context (https://www.excelbanter.com/excel-discussion-misc-queries/4095-send-tomail-all-context.html)

mariagloria

send tomail all the context
 
I miss something, I need to send by mail all the context of the folder
something like "z:\transmission\*.*" but it doesn´t work like this, do I
always have to write file by file?

--
MG

Ron de Bruin

Try this for the files in the folder C:\Data

Sub Mail_workbooks_Outlook()
Dim FNames As String
Dim MyPath As String
Dim SaveDriveDir As String
Dim OutApp As Object
Dim OutMail As Object

SaveDriveDir = CurDir
MyPath = "C:\Data" '<----- Change this path
ChDrive MyPath
ChDir MyPath

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = "
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.Body = "Hi there"

FNames = Dir("*.xls")
Do While FNames < ""
.Attachments.Add MyPath & "\" & FNames
FNames = Dir()
Loop

.display 'or use .Send
End With

Set OutMail = Nothing
Set OutApp = Nothing
ChDrive SaveDriveDir
ChDir SaveDriveDir

End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl



"mariagloria" wrote in message ...
I miss something, I need to send by mail all the context of the folder
something like "z:\transmission\*.*" but it doesn´t work like this, do I
always have to write file by file?

--
MG





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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com