Macro does not send emails

Asked

Viewed 63 times

-2

My macro does not send emails... it has the following options, open Outlook and do not send email, or send... but it just opens and does not send..

**' VERIFICAR SE DEVE ENVIAR OU APENAS EXIBIR O EMAIL
        If Worksheets("SUPORTE").[SUPORTE_TIPO_ENVIO] = "Enviar" Then
            .Display
            SendKeys "{SEND}", True ' <<< ALGUMAS VEZES NÃO ENVIAVA IMAGEM USANDO O SEND'
        Else
            .Display
            SendKeys ("^{Enviar}"), True

        End If**
  • 1

    This code does not send email it only simulates the pressing of a key. To send an email in VBA you have to activate a class object Outlook.Application.

  • I managed to solve doing this Sendkeys " {Enter}", True When opening the outlook window it presses the shortcut crtl+enter and sends... but on the machine in question it does not work

  • Instead of opening a window and simulating a click or pressing keys use the Microsoft Otlook API. I write this because user interfaces change over time, if it is not part of the Application is part of the Operating System the API also evolves but with each evolution it maintains compatibility with previous versions.

  • 1
  • 1

    @danieltakeshi you did very well in this code +1.

1 answer

0

try that way.

 If Worksheets("SUPORTE").[SUPORTE_TIPO_ENVIO] = "Enviar" Then
   .Send
Else
...

Browser other questions tagged

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