【问题标题】:How do i set Recipients property in Outlook.AppointmentItem?如何在 Outlook.AppointmentItem 中设置收件人属性?
【发布时间】:2013-10-25 16:52:28
【问题描述】:

在这个 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 ("someone@gmail.com") ' This line is not working
      ' .Display
       .Send

    End With

End Sub

我将应用程序定义或对象定义为错误。 提前致谢。

【问题讨论】:

    标签: vba excel outlook


    【解决方案1】:

    约会是个人的,仅供您自己使用。

    您必须先将其更改为会议,然后才能添加收件人。

    为此,请将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 ("someone@gmail.com") ' This line is not working
      ' .Display
       .Send
    
    End With
    End Sub
    

    【讨论】:

    • 是的。MeetingStatus 是我不知道的属性。谢谢。但我发现 .Recipients.Add() 属性在这种情况下不起作用,可能是因为此属性适用于通讯簿中的收件人。所以我通过使用 .RequiredAttendees 属性修改了上面的代码,现在它似乎工作正常。我仍然使用 Outlook 2007。
    • @DevUtkarsh 电子邮件地址始终是有效的收件人。但我很高兴看到您解决了问题。
    【解决方案2】:

    你有这样的弹出窗口吗?

    如果是这样并且如果您单击“拒绝”,那么这可以解释您的错误。发生这种情况是因为设置了对象模型保护以防止黑客通过 Outlook 对象模型访问您的电子邮件收件人。见这篇文章:

    http://msdn.microsoft.com/en-us/library/office/ff864479%28v=office.14%29.aspx

    【讨论】:

    • 问题在于他没有设置MeetingStatus 属性来将约会更改为会议。
    • 抱歉,这不是问题。问题是会议状态和添加收件人。虽然感谢您的努力。
    猜你喜欢
    • 2013-03-30
    • 1970-01-01
    • 1970-01-01
    • 2013-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多