excel - 如何在 Outlook 2007 中使用 VB 代码使用 sendonbehalfof 作为代表发送一系列 session 邀请

标签 excel vba outlook calendar

我正在尝试在 Excel 2007 中编写一些 VB 代码,该代码将在电子表格中指定的日期自动从 Outlook 2007 日历向 Excel 电子表格中列出的收件人列表发送 session 邀请。这很有用,因为我可以通过单击按钮在不同日期向不同人发送数百个 session 请求。使用以下代码从我自己的用户帐户发送时,我可以做到这一点:

' Create the Outlook session
Set myoutlook = CreateObject("Outlook.Application")
' Create the AppointmentItem
Set myapt = myoutlook.CreateItem(olAppointmentItem)     ' Set the appointment properties
With myapt
    .Subject = " Assessment Centre "
    .Location = "conference room A"
    .Start = Cells(5, 24 + j) & " 17:00:00 PM"
    .Duration = 120
    .Recipients.Add Cells(i, 1).Value
    .MeetingStatus = olMeeting
    ' not necessary if recipients are email addresses
    'myapt.Recipients.ResolveAll
    .AllDayEvent = "False"
    .BusyStatus = "2"
    .ReminderSet = False
    .Body = L1 & vbCrLf & vbCrLf & L2 & vbCrLf & vbCrLf & L3 & vbCrLf & vbCrLf & L4
        .Save
    .send
End With

但现在我想从我是代表的虚拟用户帐户发送 session 请求,使用类似“sendonbehalfof”的东西,以便虚拟日历存储所有 session 邀请,其他代表也可以使用相同的虚拟用户来操作系统用户帐号。这在使用以下代码发送电子邮件时工作正常:
Set oApp = CreateObject("Outlook.Application")
Set oMail = oApp.CreateItem(0)

With oMail
    .To = " John.Smith@John_Smith.com "
    .Subject = "Subject"
    .Body = "Body"
    .SentOnBehalfOfName = "Fred.bloggs@fred_blogs.com"
    .send
End With

电子邮件会说“我代表 Fred Bloggs”

但我无法让它与日历约会一起使用。

我用'约会'、' session 请求'、sendonbehalfof'等词搜索了高低,似乎你应该能够用'sendusingaccount'进行约会,但这似乎不起作用(它没有'不会失败,只是忽略指令并像以前一样从我自己的用户帐户发送)。

谁能告诉我该怎么做?
非常感谢。

最佳答案

如果您有权访问其他用户的邮箱,请使用 GetSharedDefaultFolder获取对用户共享日历的引用,然后使用 Folders.Items.Add将 session 添加到他们的日历中。

前任:

Dim fldr As Outlook.Folder
Dim appt As Outlook.AppointmentItem
  Set fldr = Session.GetSharedDefaultFolder(_
    Outlook.CreateRecipient("Fred.bloggs@fred_blogs.com"), _
    olFolderCalendar)
  Set appt = fldr.Items.Add
  ' set up your appointment here
  ' i.e.:
  ' With appt
  '   .Start = Cells(5, 24 + j) & " 17:00:00 PM"
  '   .Duration = 120
  ' End With
  ' make sure you call the appt.Save method to save the appt!

改编自:http://www.outlookcode.com/codedetail.aspx?id=43

关于excel - 如何在 Outlook 2007 中使用 VB 代码使用 sendonbehalfof 作为代表发送一系列 session 邀请,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11678324/

相关文章:

VBA - 如何自动更新 Microsoft Office 对象库

python - 如何提取给定单元格的值?

arrays - 从子例程返回数组给出 : Compile error: Can't assign to array

vba - ADODB查询超时

html - outlook.com、microsoft exchange 和 hotmail.com 中的空 HTML 邮件

C#。 Excel。需要以编程方式在控制台应用程序中打开的电子表格上重新应用过滤器

excel - vba 获取表格中特定单元格的范围(listobject)

vba - 复制表和创建链接的功能失败并出现错误 3011

email - 如何跳过具有任何类别标签的邮件,但处理没有标签的邮件?

html - 在 Gmail 中添加了一个空白,在 outlook 的 html 签名中