如何在 Excel 中使用 VBA 代表另一个日历发送会议请求?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11696963/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I use VBA in Excel to send out meeting requests on behalf of another calendar?
提问by user1556023
I am posting this request a second time , since although I have had a reply from JimmyPena, the solution didn't work and I do not seem to be able to add my comments as to what happened. The VBA code is in the Excel spreadsheet not Outlook.
我第二次发布此请求,因为虽然我收到了 JimmyPena 的回复,但该解决方案不起作用,而且我似乎无法对发生的事情发表评论。VBA 代码在 Excel 电子表格中,而不是 Outlook。
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:
我正在尝试在 Excel 2007 中编写一些 VB 代码,该代码将在电子表格中指定的日期自动从 Outlook 2007 日历向 Excel 电子表格中列出的收件人列表发送会议邀请。这很有用,因为我可以通过单击一个按钮在不同日期向不同的人发送数百个会议请求。使用以下代码从我自己的用户帐户发送时,我可以做到这一点:
' 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
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:
但是现在我想从我是代表的虚拟用户帐户发送会议请求,使用类似“sendonbehalfof”的东西,以便虚拟日历存储所有会议邀请,其他代表也可以使用相同的虚拟用户操作系统用户帐号。这在使用以下代码发送电子邮件时工作正常:
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
The email will say from 'me on behalf of Fred Bloggs'
该电子邮件将来自“我代表 Fred Bloggs”
But I can't get it to work with Calendar appointments.
但我无法让它与日历约会一起使用。
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.
我已经用“约会”、“会议请求”、“sendonbehalfof”等词进行了高低搜索,似乎您应该能够为与“sendusingaccount”的约会执行此操作,但这似乎不起作用(它不'不会失败,只是忽略指令并像以前一样从我自己的用户帐户发送)。
谁能告诉我如何做到这一点?. 非常感谢。
回答by competent_tech
Have you considered generating an Internet Calendar Appointment (ICA) request and emailing it? I believe that format contains delegate information that you can use.
您是否考虑过生成 Internet 日历约会 (ICA) 请求并通过电子邮件发送?我相信该格式包含您可以使用的委托信息。
Here is a linkto some Microsoft documentation on how to add this (in ASP.Net, but that shouldn't matter) and here is a linkto the IETF RFC that defines the format.
这里是一些关于如何添加它的 Microsoft 文档的链接(在 ASP.Net 中,但这应该无关紧要),这里是定义格式的 IETF RFC的链接。