英文:
Send Outlook Meeting Invitation using Excel
问题
I am looking to send meeting invitations for each row in a worksheet.
我想要为工作表中的每一行发送会议邀请。
I am able to create an item that when displayed shows as an appointment, not a meeting request that can be sent to others.
我能够创建一个项目,当显示时它显示为约会,而不是可以发送给其他人的会议请求。
I need to click on "Invite Attendees" in Outlook, and then the email addresses display, and I can send, but it would take a lot of time if I have more than a few rows.
我需要在Outlook中点击“邀请参与者”,然后显示电子邮件地址,然后我可以发送,但如果我有多行,这将需要很多时间。
This seems to be a common problem as I found this question in other forums but none have a solution that worked for me.
这似乎是一个常见的问题,因为我在其他论坛上找到了这个问题,但没有一个解决方案适用于我。
Here is one alternative I tried but it did not fix the issue:
这是我尝试的一个替代方法,但它没有解决问题:
Another alternative is to change .Display
to .Save
, but the .Send
function won't work either way, and I would then need to open the meeting request from my draft messages in Outlook.
另一个选择是将 .Display
更改为 .Save
,但无论哪种方式,.Send
函数都不起作用,然后我需要从Outlook的草稿邮件中打开会议请求。
英文:
I am looking to send meeting invitations for each row in a worksheet.
I am able to create an item that when displayed shows as an appointment, not a meeting request that can be sent to others. I need to click on "Invite Attendees" in Outlook and then the email addresses display and I can send but it would take a lot of time if I have more than a few rows.
This seems to be a common problem as I found this question in other forums but none have a solution that worked for me.
<!-- language: vba -->
Sub SendAction()
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
For Each cell In Worksheets("Action Log").Range("H5:H50").Cells
Set OutMail = OutApp.CreateItem(1)
If cell.Value Like "*@*" Then 'try with less conditions first
With OutMail
.MeetingStatus = olMeeting
.RequiredAttendees = Cells(cell.Row, "H").Value
.Subject = Cells(cell.Row, "I").Value
.Body = Cells(cell.Row, "I").Value
.Start = Cells(cell.Row, "E").Value & " " & TimeValue("8:00 AM")
.Location = "Your Office"
.Duration = 15 ' 15 minute meeting
.BusyStatus = 0 ' set as free
.ReminderSet = True 'reminder set
.ReminderMinutesBeforeStart = "20160" 'reminder 2 weeks before
.display
End With
Cells(cell.Row, "K").Value = "sent"
Set OutMail = Nothing
End If
Next cell
Application.ScreenUpdating = True
End Sub
Here is one alternative I tried but it did not fix the issue:
<!-- language: vba -->
Application.Wait DateAdd("s", 2, Now) 'waiting for 2 sec to let OL window to display.
SendKeys "%s", True 'Sending Mail.
Set olApt = Nothing
MsgBox "Invite Sent", vbInformation
Source: https://excel-buzz.blogspot.com/2015/03/automation-sending-invitation-to.html
Another alternative is to change .Display
to .Save
but the .Send
function won't work either way and I would then need to open the meeting request from my draft messages in Outlook.
答案1
得分: 0
以下是您的代码的中文翻译:
尝试这样做?
子 发送操作()
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
对于每个单元格 在工作表("操作日志")中的范围("H5:H50").单元格
Set OutMail = OutApp.CreateItem(1)
如果 cell.Value Like "*@*" Then '首先尝试较少的条件
与 OutMail
.MeetingStatus = olMeeting
.RequiredAttendees = Cells(cell.Row, "H").Value
.RequiredAttendees.Type = olRequired
.Subject = Cells(cell.Row, "I").Value
.Body = Cells(cell.Row, "I").Value
.Start = Cells(cell.Row, "E").Value & " " & TimeValue("8:00 AM")
.Location = "您的办公室"
.Duration = 15 ' 15分钟会议
.BusyStatus = 0 ' 设置为自由
.ReminderSet = True ' 设置提醒
.ReminderMinutesBeforeStart = "20160" ' 提前2周提醒
.显示
.发送
结束与
Cells(cell.Row, "K").Value = "已发送"
Set OutMail = Nothing
结束 If
下一单元格
Application.ScreenUpdating = True
结束 子
英文:
Try this?
Sub SendAction()
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
For Each cell In Worksheets("Action Log").Range("H5:H50").Cells
Set OutMail = OutApp.CreateItem(1)
If cell.Value Like "*@*" Then 'try with less conditions first
With OutMail
.MeetingStatus = olMeeting
.RequiredAttendees = Cells(cell.Row, "H").Value
.RequiredAttendees.Type = olRequired
.Subject = Cells(cell.Row, "I").Value
.Body = Cells(cell.Row, "I").Value
.Start = Cells(cell.Row, "E").Value & " " & TimeValue("8:00 AM")
.Location = "Your Office"
.Duration = 15 ' 15 minute meeting
.BusyStatus = 0 ' set as free
.ReminderSet = True 'reminder set
.ReminderMinutesBeforeStart = "20160" 'reminder 2 weeks before
.display
.send
End With
Cells(cell.Row, "K").Value = "sent"
Set OutMail = Nothing
End If
Next cell
Application.ScreenUpdating = True
End Sub
答案2
得分: 0
我明白了问题。我之前链接的电池中包含一个公式,而不是电子邮件地址文本。一旦我将电子邮件地址更改为文本而不是公式,我的VBA就可以正常工作。
英文:
I realized the issue. The cell I was linking to for the emails contained a formula instead of the email address text. Once I changed the email addresses to text instead of a formula my VBA worked perfectly.
答案3
得分: 0
我遇到了与楼主相同的问题,但我没有使用发送键,而是使用检查元素来访问“邀请参与者”功能。以下是代码的摘录:
Dim oApp As Object
Dim OutMail As Object
Dim oCommandBar As Object 'Office.CommandBars
Dim oInsp As Object 'Outlook.inspector
Set OutMail = oApp.CreateItem(1)
'然后在循环中使用以下代码来访问Ribbon:
Set oInsp = OutMail.GetInspector
Set oCommandBar = oInsp.CommandBars
'显示邮件项
OutMail.Display
'点击“邀请参与者”功能
oCommandBar.ExecuteMso ("InviteAttendees")
英文:
I had the same problem as the OP but rather than resort to send keys I used the inspector to access the Invite Attendees ribbon command. Here are excerpts from the code:
Dim oApp As Object
Dim OutMail As Object
Dim oCommandBar As Object 'Office.CommandBars
Dim oInsp As Object 'Outlook.inspector
Set outMail = oApp.CreateItem(1)
'then these in the loop to get access to the ribbon:
Set oInsp = OutMail.GetInspector
Set oCommandBar = oInsp.CommandBars
'Show the mail item
outMail.display
'Press the Invite attendees ribbon item
oCommandBar.ExecuteMso ("InviteAttendees")
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论