leogranja
09-13-2017, 09:05 AM
Guys,
I have a code that sends emails to me. I would like to check (by counting) if any of the emails doesn't have attachments. I have tried as below but it didn't work. Can you help me, please?
For Each celly In Sheets("VENDAS CONSOLIDADAS").Range("T10:T127")
If celly <> "" Then
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
Set myAttachments = OutMail.Attachments
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
anexo = ThisWorkbook.Path & "\" & Sheets("VENDAS CONSOLIDADAS").Range("U2").Value & "\" & celly.Offset(0, 1).Value & ".pdf"
On Error Resume Next
With OutMail
.display
StrSig = .HTMLbody
.To = Endereco
.CC = Endereco2
.BCC = ""
.Subject = Titulo
.HTMLbody = "<FONT FACE=Calibri (Corpo)>" & StrBody & StrSig
myAttachments.Add anexo
if Item.Attachments.Count = 0 Then
attachcount = attachcount + 1
.display
End With
Thank you very much.
I have a code that sends emails to me. I would like to check (by counting) if any of the emails doesn't have attachments. I have tried as below but it didn't work. Can you help me, please?
For Each celly In Sheets("VENDAS CONSOLIDADAS").Range("T10:T127")
If celly <> "" Then
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
Set myAttachments = OutMail.Attachments
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
anexo = ThisWorkbook.Path & "\" & Sheets("VENDAS CONSOLIDADAS").Range("U2").Value & "\" & celly.Offset(0, 1).Value & ".pdf"
On Error Resume Next
With OutMail
.display
StrSig = .HTMLbody
.To = Endereco
.CC = Endereco2
.BCC = ""
.Subject = Titulo
.HTMLbody = "<FONT FACE=Calibri (Corpo)>" & StrBody & StrSig
myAttachments.Add anexo
if Item.Attachments.Count = 0 Then
attachcount = attachcount + 1
.display
End With
Thank you very much.