2015-09-23 102 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文章很有帮助。