Send email with rows based on a column value (Through CDO_Mail...)

asantos2015

New Member
Joined
Nov 26, 2015
Messages
4
Hey guys,

I have been hitting my head with it, but being completely ignorant about VBA, it's become almost impossible for me to solve it on my own.
I have an inventory and the column O has a status showing which have reached their minimum qty. So I would need the automation to send an email with these items (rows) listed.

I need to include a piece of code that checks which rows meet a value and have them sent by email. Below is the code I got so far:
Code:
Sub CDO_Mail_Small_Text()
    Dim iMsg As Object
    Dim iConf As Object
    Dim strbody As String
    Dim Flds As Variant
       
    Set iMsg = CreateObject("CDO.Message")
    Set iConf = CreateObject("CDO.Configuration")


    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") = ""
        .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = ""
        .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 & _
        "This is line 2" & vbNewLine & _
        "This is line 3" & vbNewLine & _
        "This is line 4"


    With iMsg
        Set .Configuration = iConf
        .To = ""
        .CC = ""
        .BCC = ""
        .From = """Estoque"" <>"
        .Subject = "Atenção! Estoque de Insumos e MP baixo!"
        .TextBody = strbody
        .Send
    End With


End Sub
Thanks a million guys!
 
Last edited by a moderator:

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Adding the filtered rows to the message is missing in the instructions there and that's exactly what I need. Thanks anyway.
 
Upvote 0

Forum statistics

Threads
1,214,848
Messages
6,121,914
Members
449,054
Latest member
luca142

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top