none
Se coluna O tem "Repor", enviar a linha no corpo do email RRS feed

  • Pergunta

  • Private Sub Workbook_BeforeClose(Cancel As Boolean)

      Call CDO_Mail_Small_Text

    End Sub
    Sub CDO_Mail_Small_Text()
    Application.ScreenUpdating = False
        Dim iMsg As Object
        Dim iConf As Object
        Dim strbody As String
        Dim Flds As Variant
        Dim rng As Range
        

        Set iMsg = CreateObject("CDO.Message")
        Set iConf = CreateObject("CDO.Configuration")
        
        '   Set Source = ActiveWorkbook.Worksheets("All")
        '   Set rng = Nothing
        On Error Resume Next

        Set rng = Sheets("Estoque para Reposição").Range("a4:o100").SpecialCells(xlCellTypeVisible)
       
       
        
        iConf.Load -1    ' CDO Source Defaults
        Set Flds = iConf.Fields
        With Flds
            .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
            .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "antonio@ataldacastanha.com.br"
            .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "hope2015"
            .Update    'Let CDO know we have change the default configuration for this message
        End With
        
            strbody = "Atenção! Esses itens chegaram no estoque mínimo." & " Favor verificar imediatamente e confirmar a necessidade de compra!" & vbNewLine & _
            "" & vbNewLine & _
            "" & vbNewLine & _
            "" & vbNewLine & _
            ""

        With iMsg
            Set .Configuration = iConf
            .To = "antonio@ataldacastanha.com.br"
            .CC = "antoniosan0@hotmail.com"
            .BCC = ""
            .From = """Estoque de Insumos e MP"" <antonio@ataldacastanha.com.br>"
            .Subject = "Atenção! Estoque de Insumos e MP baixo!"
            .HTMLBody = strbody + RangetoHTML(rng)
            .Send
        End With

    End Sub
    quinta-feira, 14 de setembro de 2017 18:04

Todas as Respostas