Doubt with the Sender command of Excel objects in VBA excel

1

I have a excel VBA code which sends some specific email recipients some email's but at first these emails are being sent out because my outlook is coming out with my name but in Outlook we have the option to type from which name you want to send this e-mail that is the "DE" field. My question is, and how do I put it in the code for it to send from another name, through this "DE" field, without being by my name? Searching I found the Sender command, but when I use it it gives the message "Compile Error - Incompatible Types". Below is the line of code for sending e-mail, can you help me please.

Sub Enviar_e_mail()

Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
'Criação e chamada do Objeto Outlook
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
Application.DisplayAlerts = False

With OutMail
.Sender = "[email protected]"
.To = "[email protected]"
'.CC = ""
.BCC = ""
.Subject = "Titulo do e-mail"
.Body = "Texto do E-mail"
'O trecho abaixo anexa a planilha ao e-mail
.Attachments.Add "Arquivo a ser anexado"
.Send
End With
    
asked by anonymous 29.03.2018 / 20:12

0 answers