gửi mail hàng loạt bằng VBA nhưng không đính kèm .pdf có đường dẫn trong sheet được

Liên hệ QC
Tôi tuân thủ nội quy khi đăng bài

phamdiemhuong93

Thành viên mới
Tham gia
4/4/16
Bài viết
1
Được thích
0
chào các anh/chị
em có viết 1 code để gửi mail hàng loạt cho từng người có đính kèm file .pdf nhưng phần attachment file thì vẫn báo lỗi, nhờ các anh/chị hỗ trợ giúp em xem em sai ở đâu ạ

Sub guithu()

Dim olApp As Outlook.Application
Set olApp = CreateObject("Outlook.Application")
Dim strAttachment As String

Dim i, so_nguoi_nhan_email As Integer
so_nguoi_nhan_email = Excel.WorksheetFunction.CountA(ThisWorkbook.Sheets(1).Range("C:C"))

For i = 2 To so_nguoi_nhan_email

Dim olMail As Outlook.MailItem
Set olMail = olApp.CreateItem(olMailItem)

Dim body_message As String
body_message = ThisWorkbook.Sheets(1).Cells(2, 10)
body_message = Excel.WorksheetFunction.Substitute(Excel.WorksheetFunction.Substitute(body_message, "vendor", ThisWorkbook.Sheets(1).Cells(i, 2)), "sotien", ThisWorkbook.Sheets(1).Cells(i, 5))

strAttachment = Cells(i, 6).Value

olMail.To = ThisWorkbook.Sheets(1).cell(i, 3)
olMail.Subject = "xac nhan cong no" & ThisWorkbook.Sheets(1).cell(i, 2)
olMail.BodyFormat = olFormatHTML
olMail.body = body_message
olMail.Attachments.Add(strAttachment)
olMail.Send

Next

End Sub
 
Lỗi báo như thế nào bạn. Bỏ dấu () đi xem được không
 
Web KT
Back
Top Bottom