代码忽略传入的会议请求 [英] Code ignores incoming Meeting request

查看:58
本文介绍了代码忽略传入的会议请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于处理任何传入项目的 Outlook 代码,如果通过了给定的条件,则将仅从邮件项目在 Outlook 日历中创建一个新约会.

I have a code for Outlook that processes any incoming item and if given criteria are passed a new appointment is to be created in Outlook calendar from mail items only.

该代码不区分邮件项目和会议请求项目.这会导致系统根据会议项目在 1899 年创建一个新会议,而不是忽略它.

The code does not differentiate between mail item and meeting request item. This results in the system creating a new meeting in year 1899 from the meeting item instead ignoring this.

Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)

On Error Resume Next
Set ns = Application.Session
arr = Split(EntryIDCollection, ",")


For i = 0 To UBound(arr)
    Set itm = ns.GetItemFromID(arr(i))

    If (itm.Class = olMail) Then

        Set objMail = itm

        If objMail.Subject = "Approved" And objMail.Sender = "x@mail.com" Then

           Set Reg1 = New RegExp

           With Reg1
                   .Pattern = "([0-9]{2})(.)([0-9]{2})(.)([0-9]{4})(\s)(\W)(\s)([0-9]{2})(.)([0-9]{2})(.)([0-9]{4})"
                   .Global = True
           End With

           If Reg1.test(objMail.Body) Then

                Set M1 = Reg1.Execute(objMail.Body)

                For Each m In M1

                Set objAppt = Application.CreateItem(olAppointmentItem)
                Set objInsp = objAppt.GetInspector
                Set objDoc = objInsp.WordEditor
                Set objSel = objDoc.Windows(1).Selection

                Next
            End if
            .....

 End Sub

推荐答案

基于 OP 的评论Run-time error '13', type mismatch for the itm variable"和开发问题的解决方案,问题的答案可能会修复 On Error Resume Next 的误用,并设置编辑器以在每个模块上生成 Option Explicit.

Based on the OP's comment "Run-time error '13', type mismatch for the itm variable" and solution to the development problem, the answer to the question is likely to fix the misuse of On Error Resume Next and to set up the editor to generate Option Explicit on every module.

然后编程更改应该是:

Dim itm As Object
Dim objMail As MailItem

这篇关于代码忽略传入的会议请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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