Recipients.Add生成运行时错误"287":应用程序定义或对象定义的错误 [英] Recipients.Add generates Runtime error '287': Application-defined or object-defined error
本文介绍了Recipients.Add生成运行时错误"287":应用程序定义或对象定义的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在测试如何发送电子邮件.我已经从帮助文件中复制了以下代码:
I am testing how to send an e-mail. I have copied the code below from the help files:
Sub CreateHTMLMail()
'Creates a new e-mail item and modifies its properties'
Dim olApp As Outlook.Application
Dim objMail As Outlook.MailItem
Set olApp = Outlook.Application
'Create e-mail item'
Set objMail = olApp.CreateItem(olMailItem)
With objMail
.Subject = "Test Message"
.Body = "Body Text"
.Recipients.Add "xyz@abc.com"
.Recipients.ResolveAll
.Display
End With
End Sub
我收到一个运行时错误'287'消息,突出显示了.Recipients.Add行.我在做什么错了?
I receive a Runtime error '287' message with the .Recipients.Add line highlighted. What am I doing wrong?
推荐答案
尝试一下:
toString = "me@email.com;you@email.com;them@email.com"
With OutMail
.To = toString
.Subject = "Hello Friends"
.Body = "Here is the email body"
.Send
End With
这当然适用于多个收件人.对于单个收件人,只需执行以下操作:
This of course works with multiple recipients. For a single recipient, just do this:
toString = "oneguy@gmail.com"
请不要忘记.Send
实际发送您的电子邮件.
And don't forget the .Send
to actually make your email send.
这篇关于Recipients.Add生成运行时错误"287":应用程序定义或对象定义的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文