How can I supress the Outlook warning while sending mail using macro in excel

后端 未结 7 1655
猫巷女王i
猫巷女王i 2020-12-10 06:39

I am trying to send an email using macro in excel.

But when I run this code my mail client i.e. MS Outlook shows a pop up warning similar to
Someone is t

7条回答
  •  情歌与酒
    2020-12-10 07:24

    Adding to Julia Grant's Answer and Answering dsauce

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

    Option Compare Database
    ' Declare Windows' API functions
    Declare PtrSafe Function RegisterWindowMessage _
            Lib "user32" Alias "RegisterWindowMessageA" _
            (ByVal lpString As String) As Long
    
     Declare PtrSafe Function FindWindow Lib "user32" _
                Alias "FindWindowA" (ByVal lpClassName As Any, _
                ByVal lpWindowName As Any) As Long
    
    
    Declare PtrSafe Function SendMessage Lib "user32" _
            Alias "SendMessageA" (ByVal hwnd As Long, _
            ByVal wMsg As Long, ByVal wParam As Long, _
            lParam As Any) As Long
    
    Function TurnAutoYesOn()
    Dim wnd As Long
    Dim uClickYes As Long
    Dim Res As Long
    uClickYes = RegisterWindowMessage("CLICKYES_SUSPEND_RESUME")
    wnd = FindWindow("EXCLICKYES_WND", 0&)
    Res = SendMessage(wnd, uClickYes, 1, 0)
    
    End Function
    
    Function TurnOffAutoYes()
    Dim wnd As Long
    Dim uClickYes As Long
    Dim Res As Long
    uClickYes = RegisterWindowMessage("CLICKYES_SUSPEND_RESUME")
    wnd = FindWindow("EXCLICKYES_WND", 0&)
    Res = SendMessage(wnd, uClickYes, 0, 0)
    End Function
    
    
    Function fEmailTest()
    
    TurnAutoYesOn  '*** Add this before your email has been sent
    
    
    
    Set appOutLook = CreateObject("Outlook.Application")
    Set MailOutLook = appOutLook.CreateItem(olMailItem)
    With MailOutLook
        .To = " ;  

    I know the thread is old, but it may help somebody

提交回复
热议问题