title: VB macro to send mail without opening Lotus notes
body: <p>I want to send a mail with a vbscript without opening Lotus Notes UI. I managed to write a script that allows to send email with attachments and everything works fine. However the application is launched when I run the macro and I want it to work silenty (without launching the application).</p>
  <p>Here is my code:</p>
  <pre><code>Dim noSession As Object
  Dim noDatabase As Object
  Dim noDocument As Object
  Dim paths() As String
      
  'Instantiate the Lotus Notes COM's Objects.
  Set MailSession = CreateObject(&quot;Notes.NotesSession&quot;)
  Set MailDatabase = MailSession.GetDatabase(&quot;&quot;, &quot;&quot;)
  
  'If Lotus Notes is not open then open the mail-part of it.
  If MailDatabase.IsOpen = False Then MailDatabase.OPENMAIL
      
  'Create the list of recipients.
  vaRecipients = VBA.Array(EmailTo)
  vaCCRecipients = VBA.Array(EmailCC)
  vaBCCRecipients = VBA.Array(EmailBCC)
  Set MailDoc = MailDatabase.CreateDocument
  MailDoc.Form = &quot;Memo&quot;
  MailDoc.sendTo = vaRecipients
  MailDoc.CopyTo = vaCCRecipients
  MailDoc.BlindCopyTo = vaBCCRecipients
  MailDoc.Subject = Subject
  MailDoc.Body = Body
  MailDoc.SAVEMESSAGEONSEND = True
  MailDoc.ReplyTo = Sender
  MailDoc.SMTPOriginator = Sender
  MailDoc.Sender = Sender
  MailDoc.principal = Sender
  MailDoc.inetprincipal = Sender
  MailDoc.from = Sender
  MailDoc.inetfrom = Sender
  MailDoc.displayfrom = Sender
      
  paths = Split(AttachmentPaths, &quot;;&quot;)
  Dim richTextItem As Object
  Dim AttachmentPath As String
  For i = LBound(paths()) To UBound(paths())
      AttachmentPath = paths(i)
      Set richTextItem = MailDoc.CreateRichTextItem(&quot;Attachment&quot; &amp; i)
      Call richTextItem.EmbedObject(1454, &quot;&quot;, AttachmentPath)
  Next i
      
  MailDoc.Send 0, vaRecipients
      
  'Release objects from memory.
  Set noDocument = Nothing
  Set noDatabase = Nothing
  Set noSession = Nothing
  MsgBox &quot;The e-mail has successfully been created and distributed&quot;, vbInformation
  </code></pre>
  <p>The problem is that Lotus notes UI is launched everytime I run the macro because of this line:</p>
  <p><code>If MailDatabase.IsOpen = False Then MailDatabase.OPENMAIL</code></p>