send file by mail VBA

bhelmy

Registered User.
Local time
Today, 06:56
Joined
Dec 6, 2015
Messages
62
Hi my friends
the following code to attaches all file in folder and send it by mail auto

I need to make the code not to sent mail auto but preview the mail and I will send it manual



[ Dim mess_body As String, StrFile As String, StrPath As String
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem

Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)

'~~> Change path here
StrPath = "C:\Access"

With MailOutLook
.BodyFormat = olFormatRichText
.To = "test@testss.orwg"
.Subject = "test"
.HTMLBody = "test"
.NoAging = False

'~~> *.* for all files
StrFile = Dir(StrPath & "*.*")

Do While Len(StrFile) > 0
.Attachments.Add StrPath & StrFile
StrFile = Dir
Loop

'.DeleteAfterSubmit = False
.Send
End With

MsgBox "Reports have been sent", vbOKOnly
End Sub]
 
when I removed it
Didn't work and didn't open or sent email
 
Replace .Send with .Display
 

Users who are viewing this thread

Back
Top Bottom