获取当前用户 - 签署交换服务器 - 经理电子邮件地址

Get current user - signed to exchange server - manager email address

如何找回当前用户管理员的电子邮件地址? 我只能通过调用

来获取我的电子邮件地址

Application.Session.CurrentUser.AddressEntry.GetExchangeUser

同时使用

Application.Session.CurrentUser.AddressEntry.GetExchangeUser.Manager

returns没什么... 我想要实现的是直接从 excel sheet 向我的经理发送电子邮件并在其他用户计算机上自动发送(因为他们有其他经理)

Sub Mail_workbook_Outlook_1()
    Dim OutApp As Object
    Dim OutMail As Object

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    If IsEmpty(Range("A21").Value) = True Then ' check if cell is empty
      MsgBox "Cell is empty!", vbCritical, "It would be better to not left it empty..." ' if so, show user a message
    Else

    On Error Resume Next
    With OutMail ' outlook message details
        .To = "xyz@xyz.net"
        .Subject = "Sales report - " & Format(Date, "dd-mm-yyyy")
        .Body = "Here comes the full sales report from " & Format(Date, "dd-mm-yyyy") & Application.Session.CurrentUser.AddressEntry.GetExchangeUser
        .Attachments.Add ActiveWorkbook.FullName ' add current file as an attachment to the outlook message
        .Send
    End With
    On Error GoTo 0
    MsgBox "File sent ", vbInformation, "You can now safely close the report" ' show confirmation message

    Set OutMail = Nothing
    Set OutApp = Nothing
    End If
End Sub

获取当前用户的管理员。

示例

Option Explicit
Sub GetManager()

    MsgBox CreateObject("Outlook.Application").GetNamespace("MAPI") _
                    .CurrentUser.AddressEntry.GetExchangeUser.Manager

End Sub

编辑

记住用户必须有管理员设置。

这样修改你的代码

    With OutMail ' outlook message details
        .To = CreateObject("Outlook.Application").GetNamespace("MAPI") _
                    .CurrentUser.AddressEntry.GetExchangeUser.Manager

        .Subject = "Sales report - " & Format(Date, "dd-mm-yyyy")
        .Body = "Here comes the full sales report from " & Format(Date, "dd-mm-yyyy")
        .Attachments.Add ActiveWorkbook.FullName 'attachment File 
        .Display
'        .Send
    End With

另见 MSDN 示例

How to: Get Availability Information for an Exchange User's Manager