2015-09-23 98 views
0

我希望Outlook在所有外發郵件上提示輸入密碼或進行某種身份驗證,因爲有人繼續以我的帳戶名義發送郵件。發送時提示輸入密碼

我已經寫:

If Omail.SendUsingAccount = "My Domain Email account typed here" Then 

    Sub password() 
    Dim pass As String 
    pass = InputBox("Enter Password") 
    If pass <> "thepassword" Then Exit Sub 

End Sub 

這是行不通的。我有正確的代碼後,我可以將其插入自定義操作規則?

+0

也許這是一個代表問題。 https://support.office.com/en-us/article/Allow-someone-else-to-manage-your-mail-and-calendar-41c40c04-3bd1-4d22-963a-28eafec25926 – niton

回答

0

請使用下面的代碼:

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) 
prompt$ = "Enter Password to Send Mail" 

Dim pass As String 
    pass = InputBox("Enter Password") 
If pass <> "yourpwd" Then 
Cancel = True 
End If 
End Sub 

它的實驗,其工作的罰款。

確保您已啓用信任中心的宏。

0

您可以開發一個VBA宏,您可以在其中處理應用程序類的事件,每當用戶通過Inspector發送Microsoft Outlook項目時(在檢查器關閉之前但在用戶之後單擊發送按鈕),或者在程序中使用Outlook項目的發送方法(如MailItem)時。

例如:

Public WithEvents myOlApp As Outlook.Application 

Public Sub Initialize_handler() 
Set myOlApp = Outlook.Application 
End Sub 

Private Sub myOlApp_ItemSend(ByVal Item As Object, Cancel As Boolean) 
Dim prompt As String 
prompt = "Are you sure you want to send " & Item.Subject & "?" 
If MsgBox(prompt, vbYesNo + vbQuestion, "Sample") = vbNo Then 
    Cancel = True 
End If 
End Sub 

你可能會發現Getting Started with VBA in Outlook 2010文章很有幫助。