2014-02-14 41 views
0

好吧,所以無論何時我從某個組收到包含特定文本的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 = "[email protected]" 
     .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)。

有什麼建議嗎?

這是我更新了它,但它在我的小組自動回覆拋出一個錯誤了(項目作爲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 = "[email protected]" 
     .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 

你知道爲什麼會拋出這個錯誤?

回答

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 
+0

它在我嘗試編輯它時拋出了錯誤。我把上面的更新代碼。也許你知道爲什麼?我仍然在努力。 – ryantpayton

+0

錯誤是什麼? –

+0

沒關係我修好了。我沒有End Select語句,但即使它的工作原理相同,它仍然不會在10秒後結束。 – ryantpayton

相關問題