Ir para conteúdo
Fórum Script Brasil

glhalves

Membros
  • Total de itens

    1
  • Registro em

  • Última visita

Sobre glhalves

glhalves's Achievements

0

Reputação

  1. Olá!! Recentemente realizei uma forma de enviar Lembretes de Vencimento de Fatura, usando a integração Excel, Outlook, porém por algum motivo está somente lendo a primeira linha da planilha, se alguém puder me ajudar, ficarei grato!! Segue o código!! Sub enviar_email_vencimento() Set outlook_app = CreateObject("Outlook.Application") ultima_linha = Planilha1.UsedRange.Rows.Count For linha = 2 To ultima_linha status_envio = Cells(2, "G").Value status_pagamento = Cells(2, "E").Value vencimento = Cells(2, "F").Value If vencimento - Date <= 3 And status_envio <> "Enviado" And status_pagamento = "Pendente" Then Set msg = outlook_app.createitem(0) msg.display msg.To = Cells(2, "B").Value nome = Cells(2, "A").Value msg.Subject = "Sua fatura vence no dia " & vencimento msg.Body = "Olá " & nome & ", informamos que a sua fatura em anexo vence no dia " & vencimento anexo = Cells(2, "D").Value msg.attachments.Add anexo msg.send Cells(2, "G").Value = "Enviado" End If Next For linha = 2 To ultima_linha If vencimento - Date <= 7 And status_envio <> "Enviado" And status_pagamento = "Pendente" Then Set msg = outlook_app.createitem(0) msg.display msg.To = Cells(2, "B").Value nome = Cells(2, "A").Value msg.Subject = "Sua fatura vence no dia " & vencimento msg.Body = "Olá " & nome & ", informamos que a sua fatura em anexo vence no dia " & vencimento anexo = Cells(2, "D").Value msg.attachments.Add anexo msg.send Cells(2, "G").Value = "Enviado" End If Next For linha = 2 To ultima_linha If vencimento - Date >= 1 And status_envio <> "Enviado" And status_pagamento = "Pendente" Then Set msg = outlook_app.createitem(0) msg.display msg.To = Cells(2, "B").Value nome = Cells(2, "A").Value msg.Subject = "Sua fatura venceu no dia " & vencimento msg.Body = "Olá " & nome & ", informamos que a fatura em anexo venceu no dia " & vencimento anexo = Cells(2, "D").Value msg.attachments.Add anexo msg.send Cells(2, "G").Value = "Enviado" End If Next For linha = 2 To ultima_linha If vencimento - Date >= 5 And status_envio <> "Enviado" And status_pagamento = "Pendente" Then Set msg = outlook_app.createitem(0) msg.display msg.To = Cells(2, "B").Value nome = Cells(2, "A").Value msg.Subject = "Sua fatura venceu no dia " & vencimento msg.Body = "Olá " & nome & ", informamos que a fatura em anexo venceu no dia " & vencimento anexo = Cells(2, "D").Value msg.attachments.Add anexo msg.send Cells(2, "G").Value = "Enviado" End If Next End Sub
×
×
  • Criar Novo...