Cabeça foi feita para se pensar!!!


Dicas programação em Excel (VBA)



Enviar email via outlook

É obrigatório importar a biblioteca de classe que permite esse envio. No menu do Editor de Visual Basic acesse: Ferramentas > Referencias >Microsoft Outlook 14.0 Object Library.


Sub Envio()
Dim endereco, arquivo, destino, assunto, mensagem As String
Dim row, report As Integer
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
Application.DisplayAlerts = False
destino = teste@teste.com.br
endereco = "C:\Ususarios\meunome\Imagens\"
arquivo = "Foto.png"
assunto = "Minhas fotos"
mensagem = "Segue minha foto"
With OutMail
.To = destino
.CC = ""
.BCC = ""
.Subject = assunto
.Body = mensagem
.Attachments.Add (endereco & arquivo)
.Send
End With
Application.DisplayAlerts = True
Set OutMail = Nothing
Set OutApp = Nothing
End Sub


<-- Voltar