如何在 Outlook2007 中使用 VB 代码使用 sendonbehalfof 作为代表发送一系列会议邀请 [英] How can I use VB code in Outlook2007 to send a series of meeting invites using sendonbehalfof as a delegate

查看:71
本文介绍了如何在 Outlook2007 中使用 VB 代码使用 sendonbehalfof 作为代表发送一系列会议邀请的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to write some VB code within Excel 2007 that will automatically send out meeting invites from the Outlook 2007 Calendar, to a list of addressees listed in the excel spreadsheet, on the dates specified within the spreadsheet. This is useful because I can send out hundreds of meeting requests to different people on different dates with one click of a button. I can do this fine when sending from my own user account with the following code:

' 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

但现在我想使用sendonbehalfof"之类的方式从我是代表的虚拟用户帐户发送会议请求,以便虚拟日历存储所有会议邀请,其他代表也可以使用相同的虚拟用户帐户.这在使用以下代码发送电子邮件时效果很好:

But now I want to send the meeting request from a dummy user account for which I am a delegate using something like ’sendonbehalfof’ so that the dummy calendar stores all the meeting invites, and other delegates can operate the system as well using the same dummy user account. This works fine when sending an email with the following code:

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"

The email will say from ’me on behalf of Fred Bloggs’

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

But I can’t get it to work with Calendar appointments.

我已经用约会"、会议请求"、sendonbehalfof"等词进行了高低搜索,看起来你应该能够为使用sendusingaccount"的约会执行此操作,但这似乎不起作用(它不会失败,只是忽略指令并像以前一样从我自己的用户帐户发送).

I’ve searched high and low with words like ‘appointment’, ‘meeting request’, sendonbehalfof’ etc, and it seems you should be able to do this for appointments with ’sendusingaccount’ but this doesn’t seem to work (it doesn’t fail, just ignores the instruction and sends from my own user account as before).

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

Can anyone tell me how to do this? Thanks very much.

推荐答案

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

If you have delegate access to another user's mailbox, use GetSharedDefaultFolder to obtain a reference to the user's shared calendar, then use Folders.Items.Add to add the meeting to their calendar.

例如:

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

这篇关于如何在 Outlook2007 中使用 VB 代码使用 sendonbehalfof 作为代表发送一系列会议邀请的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆