簡體   English   中英

以編程方式禁止Outlook電子郵件使用Excel VBA發送警告消息

[英]Programmatically supress Outlook email send warning message using Excel VBA

目前,我有一組編碼,這些編碼設置為自動發送在先前用戶輸入時生成的電子郵件。

調用此方法時,它會私下生成/發送電子郵件-但要求用戶接受“確定”,“取消”或“幫助”。

如果用戶退出窗格或單擊“取消”,則不會發送電子郵件。

有辦法讓程序自動選擇命令好嗎?

Private Sub sendemail()

Dim outlookapp As Object
Dim mitem As Object
Dim cell As Range
Dim email_ As String
Dim subject_ As String
Dim body_ As String
Dim attach_ As String

'''>>>EMAIL<<<'''
Set outlookapp = CreateObject("Outlook.Application")


email_ = "SomeEmail@Email.com"
subject_ = "General Subject"
body_ = "General Message"

 'create Mail Item and send it
Set mitem = outlookapp.CreateItem(0)
With mitem
    .To = email_
    .Subject = subject_
    .Body = body_
     '.Attachments.Add "C:\FolderName\Filename.txt"
     '.Display 'To Display the message with an option to send or cancel

    .Send 'To auto-send the message
End With

End Sub

我嘗試使用以下代碼,但由於未成功,我認為我可能在錯誤的地方使用它:

Application.DisplayAlerts = False

'With function/code

Application.DisplayAlerts = True

您可以嘗試這樣的事情...

Set mitem = outlookapp.CreateItem(0)
With mitem
    .To = email_
    .Subject = subject_
    .Body = body_
     '.Attachments.Add "C:\FolderName\Filename.txt"
     .Display 'To Display the message with an option to send or cancel
     Application.Wait (Now + TimeValue("0:00:02"))
     Application.SendKeys "%s"
End With

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM