A | B | C | D | E | F |
S/N | To: | cc | Subject | Body | Path of Attachment folder |
1 | abc@email1.com | abc@email1.com | test email 1 | Hello Email | C:\Users\ABC\Desktop\SavedFolder\Folder1 |
<tbody>
</tbody>
I had a code below, possible to attach a code which will attach any file tht found in Path of Attachment folder?
If no folder or nth in the folder, it will be ignored.
Code:
Sub SendEmail()
'START of confirmation message box'
response = MsgBox("Start sending email?", vbYesNo)
If response = vbNo Then
MsgBox ("Macro Canceled!")
Exit Sub
End If
'END of confirmation message box'
Dim i As Integer, Mail_Object, Email_Subject, o As Variant, lr As Long
Dim wks As Worksheet
lr = Cells(Rows.Count, "B").End(xlUp).Row
Set Mail_Object = CreateObject("Outlook.Application")
Set wks = Worksheets("send_email")
For i = 2 To lr
With Mail_Object.CreateItem(o)
.To = wks.Range("B" & i).Value
.CC = wks.Range("C" & i).Value
.Subject = wks.Range("D" & i).Value
.Body = wks.Range("E" & i).Value
.Send
'.display 'disable display and enable send to send automatically
Application.Wait (Now + TimeValue("0:00:03")) 'Pausing an application for 3s, before next email
End With
Next i
MsgBox "E-mail successfully sent", 64
Application.DisplayAlerts = False
Set Mail_Object = Nothing
End Sub
Last edited: