在为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
答案 0 :(得分:0)
SentOnBehalfOfName属性仅在Exchange配置文件的情况下才有意义。如果是,您是否有权代表其他用户发送?
如果您使用POP3 / SMTP帐户,则需要使用SendUsingAccount属性。