- 15 Jan 2021 às 14:59
#61526
Boa tarde!
Estou usando o codigo abaixo e esta funcionando funcionando mas queria saber como escolher a conta que vai enviar.
Sub EnviarComunicadosProp()
Linha = 2
While Cells(Linha, 1) <> ""
If Cells(Linha, 7) = "" Then
'Set OutAccount = Outlook.Account(1)
Set objeto_outlook = CreateObject("Outlook.Application")
Set dEmail = objeto_outlook.CreateItem(0)
Set OutAccount = dEmail.Session.Accounts.Item(2)
dEmail.display
dEmail.To = Cells(Linha, 3).Value
'dEmail.BCC = "frank@standbygeradores.com.br"
dEmail.Subject = "Teste!"
dEmail.Body = " " & Cells(1, 28).Value & " " & Cells(Linha, 2).Value & "!" & vbNewLine & vbNewLine _
& Cells(1, 11).Value & vbNewLine & vbNewLine _
& "Atenciosamente," & vbNewLine & vbNewLine & Cells(2, 11).Value
dEmail.Attachments.Add (ThisWorkbook.Path & "\" & Range("k4"))
dEmail.Send
Cells(Linha, 7).Value = Now()
End If
Linha = Linha + 1
Wend
MsgBox "Mensagens enviadas!"
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing
End Sub
Obrigado
Estou usando o codigo abaixo e esta funcionando funcionando mas queria saber como escolher a conta que vai enviar.
Sub EnviarComunicadosProp()
Linha = 2
While Cells(Linha, 1) <> ""
If Cells(Linha, 7) = "" Then
'Set OutAccount = Outlook.Account(1)
Set objeto_outlook = CreateObject("Outlook.Application")
Set dEmail = objeto_outlook.CreateItem(0)
Set OutAccount = dEmail.Session.Accounts.Item(2)
dEmail.display
dEmail.To = Cells(Linha, 3).Value
'dEmail.BCC = "frank@standbygeradores.com.br"
dEmail.Subject = "Teste!"
dEmail.Body = " " & Cells(1, 28).Value & " " & Cells(Linha, 2).Value & "!" & vbNewLine & vbNewLine _
& Cells(1, 11).Value & vbNewLine & vbNewLine _
& "Atenciosamente," & vbNewLine & vbNewLine & Cells(2, 11).Value
dEmail.Attachments.Add (ThisWorkbook.Path & "\" & Range("k4"))
dEmail.Send
Cells(Linha, 7).Value = Now()
End If
Linha = Linha + 1
Wend
MsgBox "Mensagens enviadas!"
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing
End Sub
Obrigado