使用VBA在Lotus Notes中保存会议时,请删除“发送邀请”消息

时间:2014-02-17 17:17:10

标签: vba lotus-notes lotusscript

我正在尝试使用excel和lotus Notes创建一个生成会议邀请的工具,并且我能够使用我在StackOverflow和Lotus Notes API中找到的代码生成我想要的电子邮件。

唯一的细节是,当我尝试在日历中保存会议时(不发送它。只需保存为草稿,以便有人可以在发送邀请之前检查会议详细信息)Lotus Notes将显示以下消息: Send invitation message

有没有办法删除此邮件,以便用户不会看到此邮件? 生成会议的代码如下:

Private Sub salvaAppointment()

    'Lotus notes objects
    Set session = CreateObject("Notes.NotesSession")
    Set Db = session.GetDatabase("", "")

    'Prepare a document for the meeting
    Call Db.OPENMAIL
    Set doc = Db.CreateDocument
    Set richText = doc.CreateRichTextItem("Body")

    'Set meeting properties
    Call doc.ReplaceItemValue("Form", "Appointment")
    Call doc.ReplaceItemValue("AppointmentType", "3")
    doc.Subject = "Reunião Caixa Rápido"
    doc.CALENDARDATETIME = DateAdd("h", 15, Date)
    doc.StartDateTime = DateAdd("h", 15, Date)
    doc.EndDateTime = DateAdd("h", 17, Date)
    doc.StartDate = Date
    doc.Location = "Sala CCB"

    'Email body
    Call richText.AppendText("Modelo A3: ")
    Call richText.AddNewLine(1, True)
    modA3 = Application.ActiveWorkbook.Path & "\A3 Mod Modelo teste.ppt"
    Call richText.EmbedObject(1454, modA3, modA3, "Attachment")
    Call richText.AddNewLine(2, True)
    Call richText.AppendText("**template**")
    Call richText.Update

    'Opens UI object to edit the document
    Set UIWorkSpace = CreateObject("Notes.NotesUIWorkspace")
    Set uidoc = UIWorkSpace.EDITDocument(True, doc)

    'Fills meeting required destination
    Set nomes = Range(Range("F1"), Range("F" & Rows.Count).End(xlUp))
    For Each nome In nomes
        Call uidoc.FieldAppendText("EnterSendTo", nome & ",")
    Next nome

    'Copy Excel cells to clipboard
    Dim lastRow As Integer
    lastRow = Range("E" & Rows.Count).End(xlUp).Row
    Range("A1:E" & lastRow).Copy                'CHANGE SHEET AND RANGE TO BE COPIED AND PASTED
    'Create a temporary Word Document
    Set WordApp = CreateObject("Word.Application")
    WordApp.Visible = False                                 'True to aid debugging
    Set wdTemplate = WordApp.Documents.Open(Application.ActiveWorkbook.Path & "\templateEmail.doc")
    'Paste into Word document and copy to clipboard
    With wdTemplate.Bookmarks
        .item("tabela").Range.PasteSpecial DataType:=10
    End With
    With WordApp.Selection
        .WholeStory
        .Copy
    End With

    'Find the marker text in the Body item
    uidoc.GotoField ("Body")
    uidoc.FINDSTRING "**template**"
    'Paste from clipboard (Word) to Lotus Notes document
    uidoc.Paste
    Application.CutCopyMode = False
    WordApp.Quit False

    'When I call the below line, it displays the message
    Call uidoc.Save

    uidoc.Close

    'Liberar memória
    Set session = Nothing
    Set UIWorkSpace = Nothing

    'Deleta as planilhas temporárias
    Sheets("dados").Delete
    Sheets("temp").Delete

End Sub

我感谢任何帮助。

1 个答案:

答案 0 :(得分:1)

Notes识别名为MailOptions的保留字段,该字段用于在保存文档时控制自动发送电子邮件。尝试在您使用“设置会议属性”评论的代码块中添加此内容:

doc.ReplaceItemValue("MailOptions","0")