

'Get a reference the inspector obj (the window the mail item is displayed in) 'Give outlook some time to display the messageĪpplication.Wait (Now + TimeValue("0:00:05")) Set objMail = olApp.CreateItem(olMailItem) Set olApp = CreateObject("Outlook.Application") Set olApp = GetObject(, "Outlook.Application") 'Check whether outlook is open, if it is use get object, if not use create object
#Outlook 2016 cannot send popup code
The code is shown below: Dim olApp As outlook.Application the window it is in and activate it immediately prior to the call to sendkeys. To make it more robust I get the inspector for the mail item i.e. The drawback is that the sendkeys method can be a bit buggy. The best way I know is to create an outlook application item, create the message, display the message and use sendkeys to send the message (equivelent of typing alt s).

I know the thread is old, but it may help somebody TurnOffAutoYes '*** Add this after your email has been sent Set MailOutLook = appOutLook.CreateItem(olMailItem) Set appOutLook = CreateObject("Outlook.Application") TurnAutoYesOn '*** Add this before your email has been sent UClickYes = RegisterWindowMessage("CLICKYES_SUSPEND_RESUME") Lib "user32" Alias "RegisterWindowMessageA" _ĭeclare PtrSafe Function FindWindow Lib "user32" _Īlias "FindWindowA" (ByVal lpClassName As Any, _ĭeclare PtrSafe Function SendMessage Lib "user32" _Īlias "SendMessageA" (ByVal hwnd As Long, _īyVal wMsg As Long, ByVal wParam As Long, _ In the declaration section Option Compare Databaseĭeclare PtrSafe Function RegisterWindowMessage _

This should be fixed by replacing Private Declare Function with Declare PtrSafe Function When used Julia' Code directly I got the error RegisterWindowMessage
