Adding attachments automatically via Microsoft Access

Hi,

I am trying to get a MS Access database to generate a Lotus Notes email with pre populated text and append at least 1 attachment.

We are able to get the email generated OK and ready to send but cannot find the right code to add an attachment.

The code we are using to create the mail is below, I would appreciate any help on getting the last bit of the code.

Public Sub ComposeMemo(ByVal recipient As String, ByVal subject As String, ByVal Mtxt As String)

    Dim sess As Object

    Set sess = CreateObject("Notes.NotesSession")

    

    Dim ws As Object

    Set ws = CreateObject("Notes.NotesUIWorkspace")

    

    Dim mailServer As String

    mailServer = sess.GetEnvironmentString("MailServer", True)

    

    Dim mailFile As String

    mailFile = sess.GetEnvironmentString("MailFile", True)

    

    Dim sendTo As String

    sendTo = recipient

    

    Dim bodytext As String

    bodytext = Mtxt

    

    Dim uidoc As Object

    Set uidoc = ws.ComposeDocument(mailServer, mailFile, "Memo")

             

    Call uidoc.fieldsettext("EnterSendTo", sendTo)

    Call uidoc.fieldsettext("Subject", subject)

    Call uidoc.fieldsettext("Body", bodytext)

     

    AppActivate (uidoc.WindowTitle)





End Sub

Subject: Use the Backend classes

Rather than using the UIDoc to build your note, use a NotesDocument object. From there you can create a RichTextFieldItem (Body) and use it’s method to attach a file.

Once it’s created, you can use the notesUIDocument = notesUIWorkspace.EditDocument method to open it in the client for the user to interact with.