0
Sub Email()
Dim z, i, count As Integer
Dim r(100000), s(100000), t(100000), u(100000), v(100000), w(100000) As String
Dim a As String
a = txtDataDOU.Value
count = 0
For i = 1 To z
If Cells(i, 4).Value = a Then
r(i) = txtDataDespacho
s(i) = txtNumeroDespacho.Value
t(i) = txtDataDOU.Value
u(i) = txtOrdem.Value
v(i) = txtLink.Value
w(i) = txtResumo.Value
count = count + 1
End If
Next
txtDataDespacho.Value = ""
txtNumeroDespacho.Value = ""
txtDataDOU.Value = ""
txtOrdem.Value = ""
txtLink.Value = ""
txtResumo.Value = ""
Dim objeto_outlook As Outlook.Application
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application") 'Objeto para Outlook
Set OutMail = OutApp.CreateItem(0) 'Objeto para email dentro do Outlook
For i = 1 To count + 1
With OutMail
.display
.to = Cells(14, 1).Value
.Subject = "Atos do dia " & a
.Body = "Daespacho N° " & r(count) & vbNewLine & vbNewLine & w(i) & vbNewLine & vbNewLine & " Link: " & v(i)
End With
Next
MsgBox "E-mail enviado com sucesso !!!", vbInformation, "Informação"
End Sub
Two questions: did you set the value of Z? Without this, it will probably be 0 and the loop will not iterate once.
– César Rodriguez
Sub
Email call is in which module? If you are in the module of the same form that contains theTextbox
all right, but if you’re in a different module, you have a scope problem. In this case, to reference the contents of the text boxes it will be necessary to set a variable with the objectForm
and useminhaVariavel.txtDataDespacho.Value
.– César Rodriguez
Thank you, I’ve solved my problem.
– Bruno RA