Good day to all.
I need a code that will send with e-mail (outlook) all files from a defined folder. In that folder will be max 10 PDF files.
Thanks in advance.
Best regards,
Forfiett
Good day to all.
I need a code that will send with e-mail (outlook) all files from a defined folder. In that folder will be max 10 PDF files.
Thanks in advance.
Best regards,
Forfiett
Hi,
Maybe this
Thanks![]()
Sub SendFilesInFolder() Dim otApp As Object Dim otEmail As Object Dim fso As Object Dim fsoFolder As Object Dim fsoFile As Object Const strFOLDER_PATH As String = "C:\Users\Alfred\Desktop\x" ' Initialize the variables Set otApp = CreateObject("Outlook.Application") Set otEmail = otApp.CreateItem(0) Set fso = CreateObject("Scripting.FileSystemObject") Set fsoFolder = fso.GetFolder(strFOLDER_PATH) ' Create the email With otEmail .To = "my@gmail.com" .Subject = "Files Enclosed" .Body = "Pleasse find attached the requested files." ' Loop through the files in folder and add them For Each fsoFile In fsoFolder.Files .Attachments.Add fsoFile.Path, 1 Next .Display ' If you want to send it directly then uncomment below '.Send End With ' Clean up Set otApp = Nothing Set otEmail = Nothing Set fso = Nothing Set fsoFolder = Nothing Set fsoFile = Nothing End Sub
Dear,
thanks, it is working perfectly..but it is possible to use HTMLBody..how to do it?
Hi,
Try this. Now heads up HTMLbody can be a headache lol Things not always come out the way you want them to so you might need to play with the HTML section of the body for a bit before you get expected output.
Thanks![]()
Option Explicit Sub SendFilesInFolder() Dim otApp As Object Dim otEmail As Object Dim fso As Object Dim fsoFolder As Object Dim fsoFile As Object Const strFOLDER_PATH As String = "C:\Users\Alfred\Desktop\x" ' Initialize the variables Set otApp = CreateObject("Outlook.Application") Set otEmail = otApp.CreateItem(0) Set fso = CreateObject("Scripting.FileSystemObject") Set fsoFolder = fso.GetFolder(strFOLDER_PATH) ' Create the email With otEmail .To = "my@gmail.com" .Subject = "Files Enclosed" .BodyFormat = 2 .HTMLBody = "<HTML><BODY><b>Please</b> find attached the requested files. </BODY></HTML>" ' Loop through the files in folder and add them For Each fsoFile In fsoFolder.Files .Attachments.Add fsoFile.path, 1 Next .Display ' If you want to send it directly then uncomment below '.Send End With ' Clean up Set otApp = Nothing Set otEmail = Nothing Set fso = Nothing Set fsoFolder = Nothing Set fsoFile = Nothing End
Dear,
Thanks for help. Suggest to use HTML5, as bellow:
"<span style='font-family:calibri;font-size:11pt'>" & "Good day," & "<br"> & _
Best regards,
forfiett
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks