发送与Google日历兼容的Outlook会议请求

时间:2013-10-30 09:36:31

标签: excel vba excel-vba outlook outlook-vba

我打算使用Excel中的代码为每个人创建单独的Outlook会议邀请,将单个邮件中的.ics格式的邀请附加到收件人,让他们选择是否要将邀请添加到他们的日历中。

我有大约200个邀请函要发送,我使用添加到Outlook 2013的Google Mail帐户。

代码选择主题&来自电子表格中的表格的收件人邮件ID(以及邮件正文,我已将其删除)。

通过该代码,通过Gmail帐户发送的邀请会自动添加到Google日历中,而不会将收件人/与会者/来宾列表导入Google日历。在指定日期和时间的Google日历中添加了一个事件,会议正文将导出到事件的“说明”字段,但“会员列表”显示为空!

当我在Outlook中手动添加测试会议并从Outlook发送邮件中的.ics文件时,Google日历会自动导入事件并将收件人列表添加到事件的访客列表中。

我对以下内容感到困惑:

  1. iCal文件的哪个属性会捕获Google日历导入的“收件人”列表?

  2. 是否可以替代将iCal文件保存到磁盘的代码,这些代码可以使用Outlook新会议窗口中的“转发为附件”工具?

  3. 我使用iCal文件中的VBA代码设置的提醒似乎不会打扰Google日历中的会议。我如何有效地使用它,或者这是一个只有Outlook识别的功能?

  4. 以下是我的代码:

    Sub CalendarInvite()
    
    Dim Rng As Range, strFileName As String, strRecipient As String
    Dim strSubject As String, strBody As String
    Set myoutlook = CreateObject("Outlook.Application")
    
    For Each Rng In Range("tblData[Status]")
        If Rng = "To be Sent" Then
    
            Set myapt = myoutlook.CreateItem(olAppointmentItem)
            strSubject = Cells(Rng.Row, Range("tblData[Subject]").Column)
            strFileName = "C:\Users\Test\Downloads\CalendarInvites\" & _
                Cells(Rng.Row, Range("tblData[Email]").Column) & ".ics"
            strRecipient = Cells(Rng.Row, Range("tblData[Email]").Column)
            strBody = "Test Mail Body"
            With myapt
                .MeetingStatus = olMeeting
                .Subject = " Wedding Reception - Ramya & Mohan "
                .Location = " PJN Mahal, #10, Egabaram Salai, Udaya Nagar, Porur, Chennai 116 "
                .Start = "28-12-2013 07:00 PM"
                .Duration = 150
                .AllDayEvent = "False"
                .BusyStatus = "2"
                .ReminderSet = True
                .ReminderMinutesBeforeStart = 2880
                .ResponseRequested = True
                .Body = strBody
            End With
    
            Set myRequiredAttendee = myapt.Recipients.Add(strRecipient)
            myRequiredAttendee.Type = olRequired
    
            With myapt
                .SaveAs strFileName, olICal
                .Delete
            End With
    
            Set mymail = myoutlook.CreateItem(olMailItem)
            With mymail
                .To = strRecipient
                .Subject = strSubject
                .Body = strBody
                .Importance = olImportanceHigh
                .ReadReceiptRequested = True
                .Attachments.Add strFileName
                If Cells(Rng.Row, Range("tblData[Attachment]").Column) = "Yes" Then
                    mymail.Attachments.Add "D:\Directions-PJNMahal.jpg"
                End If
                .Send
            End With
    
            Rng = "Sent, Subject to Delivery"
    
        End If
    Next Rng
    
    End Sub
    

0 个答案:

没有答案