Hi,
i need to add to my VBA code multiple attachments possibility loop till 5 attachment
from column F to J if blank resume to next
please could anyone help
thank you
note:beow the code , attached the file
Sub SendEmail(what_address As String, CCs As String, subject_line As String, mail_body As String, FilePathtoAdd As String)
Dim OlApp As Outlook.Application
Set OlApp = CreateObject("Outlook.Application")
Dim OlMail As Outlook.MailItem
Set OlMail = OlApp.CreateItem(olMailItem)
Dim myAttachments As Outlook.attachments
Set myAttachments = OlMail.attachments
OlMail.To = what_address
OlMail.CC = CCs
OlMail.Subject = subject_line
OlMail.Body = mail_body
OlMail.attachments.Add FilePathtoAdd
OlMail.Send
End Sub
Sub SendMassEmail()
row_number = 1
column_number = 1
Do
DoEvents
row_number = row_number + 1
'Do
'DoEvents
'column_number = column_number + 1
'If FilePathtoAdd <> "" Then
' OlMail.attachments.Add FilePathtoAdd
' End If
' If OlMail.attachments.Count <> 0 Then
' For Each myAttachments In OlMail.attachments
' myAttachments.Item(i).SaveAsFile FilePathtoAdd
'
' i = i + 1
' Next myAttachments
' Msg.UnRead = False
' End If
Dim mail_body_message As String
Dim full_name As String
Dim Invoice_period As String
Dim Link As String
mail_body_message = Sheet1.Range("K2")
full_name = Sheet1.Range("C" & row_number)
Invoice_period = Sheet1.Range("E" & row_number)
mail_body_message = Replace(mail_body_message, "replace_name_here", full_name)
mail_body_message = Replace(mail_body_message, "Invoice_period_replace", Invoice_period)
Call SendEmail(Sheet1.Range("A" & row_number), Sheet1.Range("B" & row_number), Sheet1.Range("D" & row_number), mail_body_message, Sheet1.Range("F" & row_number))
Loop Until row_number = 6
'Loop Until column_number = 5
MsgBox "Mass Emails Sent Succesfully !"
End Sub
Bookmarks