Error to VBA to send e-mail

Asked

Viewed 135 times

1

Good afternoon,

I am trying to use the function below, however when it opens the outlook gives the following error message "Program trying to send email in its name. If this is unexpected, click deny and check if the software Antivirus is up to date.)"

Set OutApp = CreateObject("Outlook.Application")


OutApp.Session.Logon


Set OutMail = OutApp.CreateItem(0)


    On Error Resume Next


    With OutMail
       .To = "" '''para quem vai, colocar os destinatários e separar com ;
       .cc = "" '''quem será copiado no e-mail separar com ;
       .BCC = "" ''' com cópia oculta se houver
       .Subject = "" ''' Titulo do e-mail
       .Attachments.Add " " '''colocar o caminho do arquivo se for anexar algo


       '''Aqui é o corpo do e-mail, o que será inserido nele.



       '.Send para enviar direto e .Display para visualizar antes de enviar
       .Send '''ou . Display

    End With





Application.Quit
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.