Excel 发送邮件时发生VBA运行时错误(Office 2013)

Excel 发送邮件时发生VBA运行时错误(Office 2013),excel,vba,outlook,ms-office,Excel,Vba,Outlook,Ms Office,下面是为Office 2007编写但在Office 2013上运行的VBA代码,我得到一个运行时错误 Run-time error '2147417851 (800010105)' Method 'SendOnBehalfOfName' of object '_MailItem' failed 代码如下: Dim outobj As Object Set outobj = CreateObject("Outlook.Application") Set mail = outobj.Create

下面是为Office 2007编写但在Office 2013上运行的VBA代码,我得到一个运行时错误

Run-time error '2147417851 (800010105)'
Method 'SendOnBehalfOfName' of object '_MailItem' failed
代码如下:

Dim outobj As Object

Set outobj = CreateObject("Outlook.Application")
Set mail = outobj.CreateItem(0)

With Workbooks("Report.xlsm").Worksheets("Support")
    mail.SentOnBehalfOfName = .Range(.Range("B:B").Find("Sender").Address).Offset(0, 1)
    mail.To = .Range(.Range("B:B").Find("To1").Address).Offset(0, 1)
    mail.Cc = .Range(.Range("B:B").Find("To2").Address).Offset(0, 1)
    mail.Subject = .Range(.Range("B:B").Find("Obj").Address).Offset(0, 1)
    attach = .Range(.Range("B:B").Find("Attach").Address).Offset(0, 1)
    Dim strBody As String
    strBody = "Attached the Daily Report and below relevant statistics." & vbCrLf _
    & " " & vbCrLf _
    & .Range(.Range("B:B").Find("text1").Address).Offset(0, 1) 

    mail.Body = strBody

End With
该属性仅在Exchange配置文件的情况下才有意义。如果是,您是否有权代表其他用户发送


如果使用POP3/SMTP帐户,则需要使用该属性

在我的机器上运行良好-这就是全部代码吗?您试图分配给
SentOnBehalfOfName
属性的实际值/字符串是多少?