在此 Excel VBA 代码中,我尝试在 Outlook 中创建一个新约会,我想要的是通过电子邮件发送该约会,即我想邀请用户参加该约会。
我不确定是否需要为此创建一个新的 Outlook.recipients 对象,或者我没有正确使用 .Recipeint.Add 属性。
Sub app()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.AppointmentItem
Set OutApp = New Outlook.Application
Set OutMail = OutApp.CreateItem(olAppointmentItem)
With OutMail
.Location = " happening"
.Subject = " Event check "
.Start = "8:00 PM" & Format(Date)
.End = "9:00 PM" & Format(Date)
.Body = "this is event details"
.Recipients.Add ("<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="31425e5c545e5f5471565c50585d1f525e5c" rel="noreferrer noopener nofollow">[email protected]</a>") ' This line is not working
' .Display
.Send
End With
End Sub
我收到应用程序定义或对象定义错误。 提前致谢。
最佳答案
预约是私有(private)的且仅供您使用。
您必须先将其更改为 session ,然后才能添加收件人。
为此,请将 AppointmentItem.MeetingStatus = olMeeting
添加到您的代码中。所以对于你的代码来说它是
Sub app()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.AppointmentItem
Set OutApp = New Outlook.Application
Set OutMail = OutApp.CreateItem(olAppointmentItem)
With OutMail
.MeetingStatus = olMeeting
.Location = " happening"
.Subject = " Event check "
.Start = "8:00 PM" & Format(Date)
.End = "9:00 PM" & Format(Date)
.Body = "this is event details"
.Recipients.Add ("<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7a0915171f15141f3a1d171b131654191517" rel="noreferrer noopener nofollow">[email protected]</a>") ' This line is not working
' .Display
.Send
End With
End Sub
关于vba - 如何在 Outlook.AppointmentItem 中设置 Recipients 属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19595434/