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:
Thanks a million 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
Last edited by a moderator: