发送 Outlook 会议邀请使用 Excel

huangapple go评论67阅读模式
英文:

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(&quot;Outlook.Application&quot;)

    For Each cell In Worksheets(&quot;Action Log&quot;).Range(&quot;H5:H50&quot;).Cells
        Set OutMail = OutApp.CreateItem(1)
        If cell.Value Like &quot;*@*&quot; Then      &#39;try with less conditions first
            With OutMail
                .MeetingStatus = olMeeting
                .RequiredAttendees = Cells(cell.Row, &quot;H&quot;).Value
                .Subject = Cells(cell.Row, &quot;I&quot;).Value
                .Body = Cells(cell.Row, &quot;I&quot;).Value
                .Start = Cells(cell.Row, &quot;E&quot;).Value &amp; &quot; &quot; &amp; TimeValue(&quot;8:00 AM&quot;)
                .Location = &quot;Your Office&quot;
                .Duration = 15 &#39; 15 minute meeting
                .BusyStatus = 0 &#39; set as free
                .ReminderSet = True &#39;reminder set
                .ReminderMinutesBeforeStart = &quot;20160&quot; &#39;reminder 2 weeks before
                .display                
            End With
            
            Cells(cell.Row, &quot;K&quot;).Value = &quot;sent&quot;
            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(&quot;s&quot;, 2, Now)       &#39;waiting for 2 sec to let OL window to display.
SendKeys &quot;%s&quot;, True                         &#39;Sending Mail.
Set olApt = Nothing
    
MsgBox &quot;Invite Sent&quot;, 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(&quot;Outlook.Application&quot;)

For Each cell In Worksheets(&quot;Action Log&quot;).Range(&quot;H5:H50&quot;).Cells
    Set OutMail = OutApp.CreateItem(1)
    If cell.Value Like &quot;*@*&quot; Then      &#39;try with less conditions first
        With OutMail
            .MeetingStatus = olMeeting
            .RequiredAttendees = Cells(cell.Row, &quot;H&quot;).Value
            .RequiredAttendees.Type = olRequired
            .Subject = Cells(cell.Row, &quot;I&quot;).Value
            .Body = Cells(cell.Row, &quot;I&quot;).Value
            .Start = Cells(cell.Row, &quot;E&quot;).Value &amp; &quot; &quot; &amp; TimeValue(&quot;8:00 AM&quot;)
            .Location = &quot;Your Office&quot;
            .Duration = 15 &#39; 15 minute meeting
            .BusyStatus = 0 &#39; set as free
            .ReminderSet = True &#39;reminder set
            .ReminderMinutesBeforeStart = &quot;20160&quot; &#39;reminder 2 weeks before
            .display
            .send
        
        End With
        
        Cells(cell.Row, &quot;K&quot;).Value = &quot;sent&quot;
        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 &#39;Office.CommandBars
Dim oInsp As Object &#39;Outlook.inspector
        
Set outMail = oApp.CreateItem(1)

&#39;then these in the loop to get access to the ribbon:

Set oInsp = OutMail.GetInspector
Set oCommandBar = oInsp.CommandBars

&#39;Show the mail item
outMail.display

&#39;Press the Invite attendees ribbon item
oCommandBar.ExecuteMso (&quot;InviteAttendees&quot;)

huangapple
  • 本文由 发表于 2020年1月3日 22:17:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/59580117.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定