【问题标题】:outlook 2010 - warning popup before sending email from personal mailOutlook 2010 - 从个人邮件发送电子邮件之前的警告弹出窗口
【发布时间】:2018-06-26 04:54:55
【问题描述】:

我在工作中使用了 Outlook 2010,并将我的个人邮件 ID 链接为主帐户,而组中的其他共享邮件 ID 在服务器级别链接。

所以当我从群组发送新邮件时,它默认选择个人邮件 ID,用户每次都必须更改它。

From 被选为我的个人ID 时,我使用下面的宏来提供弹出警告,但是即使在From 中选择了共享邮件ID,此宏也会发出警告。

如果From 不是主 ID 或个人 ID,或者当基于群组共享邮件 ID 创建新电子邮件时是否有宏自动选择 From,如何防止出现警告?


Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
If InStr(LCase(Item.SendUsingAccount), "sara@example.com.") Then
    Prompt$ = "You sending this from sara@example.com. Are you sure you want to send it?"
    If MsgBox(Prompt$, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Check Address") = vbNo Then
        Cancel = True
    End If
End If
End Sub 

【问题讨论】:

    标签: vba outlook


    【解决方案1】:

    From 对应于 SentOnBehalfOfName 属性。在发送邮件之前这是空的,除非您在发送前在代码中设置它。在这里没有用,因为您想验证您是否忘记设置它。

    Private Sub SetFrom()
    
    Dim curritem As mailItem
    Dim uPrompt As String
    
    Set curritem = CreateItem(olMailItem)
    
    curritem.Display
    
    uPrompt = "This mail has not been sent." & vbCr & vbCr
    uPrompt = uPrompt & "The SentOnBehalfOfName (From) property is empty unless set in the code." & vbCr & vbCr
    uPrompt = uPrompt & "See between the quotes." & vbCr & vbCr
    MsgBox uPrompt & Chr(34) & ActiveInspector.currentItem.SentOnBehalfOfName & Chr(34)
    
    ' Note: The From in the user interface does not populate the property."
    
    curritem.SentOnBehalfOfName = "sharedmailbox@example.com"
    
    ' For demonstration purposes. Not necessary to display in real code.
    curritem.Close olSave
    curritem.Display
    
    MsgBox "SentOnBehalfOfName set in the code." & vbCr & vbCr & _
        "The SentOnBehalfOfName (From) is set to: " & curritem.SentOnBehalfOfName
    
    ExitRoutine:
        Set curritem = Nothing
    
    End Sub
    

    您验证 SendUsingAccount 的尝试可能会失败,因为您拥有一个拥有多个邮箱且需要多个帐户的帐户。

    Sub Account_name()
    
    Dim olAcct As account
    Dim countAcc As Long
    Dim i As Long
    
    countAcc = Session.Accounts.count
    
    For i = 1 To countAcc
        Debug.Print "Account.....: " & i
        Debug.Print " DisplayName: " & Session.Accounts.Item(i).DisplayName
        Debug.Print " UserName   : " & Session.Accounts.Item(i).userName
        Debug.Print
    Next
    
    End Sub
    

    如果您发现自己只有一个帐户,请参阅Add an email account to Outlook 以添加帐户(如果您拥有所需的权限)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-19
      • 1970-01-01
      • 1970-01-01
      • 2012-07-29
      • 2014-03-03
      • 1970-01-01
      • 2018-07-24
      相关资源
      最近更新 更多