好的,所以每当我从某个组中收到包含某个文本的Outlook的消息时,我就会运行一个脚本。
我有它运行这个模块:
Sub AutoReply(Item As Outlook.MailItem)
msg = MsgBox("Would you like to reply to '" & Item.Subject & "' from '" & Item.SenderName & "'?", vbYesNo, "A Helpful Hand")
If msg = vbYes Then
GoTo SendEmail
Else
GoTo Die
End If
SendEmail:
Dim olkReply As Outlook.MailItem
Set olkReply = Item.Reply
With olkReply
.To = "TestEmail@test.com"
.Subject = "RE: " & Item.Subject
.HTMLBody = "<p style='font-family:calibri;font-size:15px;margin-bottom:.0001pt;color:#1f497d;'>Auto Reply Test</p><p style='font-family:tahoma;font-size:15px;color:#17365d;margin-bottom:.0001pt;'>Test</p>" & olkReply.HTMLBody
.DeferredDeliveryTime = Date + 0.07
.Send
End With
Set olkReply = Nothing
Die:
Set olkReply = Nothing
End Sub
这很有效,但我唯一想做的就是,每当弹出消息框时,如果没有选择选项,我希望它在10秒后消失。我要么只想取消它,要么选择选项vbNo(GoTo Die)。
有什么建议吗?
这是我更新的内容,但它在我的Sub AutoReply(Item as Outlook.MailItem)上抛出错误
Sub AutoReplyTest(Item As Outlook.MailItem)
Set objWSH = CreateObject("Wscript.Shell")
intResult = objWSH.Popup("Would you like to reply to '" & Item.Subject & "' from '" & Item.SenderName & "'?", 10, "A Helpful Hand", vbYesNo)
Select Case intResult
Case 6:
Dim olkReply As Outlook.MailItem
Set olkReply = Item.Reply
With olkReply
.To = "Test@Test.com"
.Subject = "RE: " & Item.Subject
.HTMLBody = "<p style='font-family:calibri;font-size:15px;margin-bottom:.0001pt;color:#1f497d;'>Test</p><p style='font-family:tahoma;font-size:15px;color:#17365d;margin-bottom:.0001pt;'>Test</p>" & olkReply.HTMLBody
.DeferredDeliveryTime = Date + 0.07
.Send
End With
Set olkReply = Nothing
Case 7, -1:
Set olkReply = Nothing
End Sub
你知道为什么会出现这个错误吗?
答案 0 :(得分:1)
试试这个:
Set objWSH = CreateObject("Wscript.Shell")
intResult = objWSH.Popup("Here is my message", 10, "Here is My Title", vbYesNo)
这将显示10秒的消息(第二个参数)。可能的结果是:
-1 Timed Out
1 OK button
2 Cancel button
3 Abort button
4 Retry button
5 Ignore button
6 Yes button
7 No button