gpt4 book ai didi

excel - 使用 Excel VBA 以编程方式禁止 Outlook 电子邮件发送警告消息

转载 作者:行者123 更新时间:2023-12-04 20:56:35 24 4
gpt4 key购买 nike

目前,我有一组编码设置为自动发送根据先前用户输入生成的电子邮件。

当它被调用时,它会私下生成/发送一封电子邮件——但要求用户接受“好的”、“取消”或“帮助”。

如果用户退出 Pane 或单击取消,则不会发送电子邮件。

有没有办法让程序自动选择命令好吗?

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

关于excel - 使用 Excel VBA 以编程方式禁止 Outlook 电子邮件发送警告消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46427256/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com