Macro to send multiple files or folder to ONE receipent in Lotus Notes

Dillon66

New Member
Joined
May 9, 2016
Messages
3
Hi Guys,

I was given a link to a post on this site for a macro code that can send attachments in lotus notes by reading a list of recipients and file paths collated in excel. This macro works brilliantly sending one file per email. However, I now need to tweak it so that it can send a number of files to one email address but on the same email instead of individual emails. Alternatively, if it would be easier, referencing a folder name containing the files and sending the folder attached to an email, preferably in a Zip folder.

I am new to VBA and self teaching so can understand how to change this code to my files but I am struggling to write the code to send only one email. I have attached the file I use to store the file paths - the top section is an example of the individual files and the bottom line is an example of a folder name we use.

Could you please have a look and offer any suggestions of the code that would do this for me?

Code:
Public Sub Send_Email_With_Multiple_Statements()

    Dim NSession As Object
    Dim NDb As Object
    Dim NDocument As Object
    Dim NRTItem As Object
    Dim SendToRecip As Variant
    Dim CopyToRecip As Variant
    Dim lastRow As Long, r As Long
    Dim UserName As String
    
    Set NSession = CreateObject("Notes.NotesSession")
    Set NDb = NSession.GetDatabase("", "")
    NDb.OPENMAIL
    
    lastRow = Cells(Rows.Count, "A").End(xlUp).Row

    For r = 2 To lastRow
        Set NDocument = NDb.CreateDocument
        With NDocument
            .Form = "Memo"
            .Subject = "Commission Statement"
            .sendto = Cells(r, "C").Value
            .copyto = Cells(r, "D").Value
            .body = "** In Confidence**" & vbLf & vbLf & _
                "Hello " & Cells(r, "A") & vbLf & vbLf & _
                "Please find attached your team's commission statements for " & Cells(r, "F") & vbLf & vbLf & _
                "If you are happy, please forward out to the individuals." & vbLf & vbLf & _
                "Please note: All queries need to be returned to me by COB on " & Cells(r, "G") & vbLf & vbLf & _
                "Kind regards,"
            
            If Dir(Cells(r, "E").Value) <> "" Then
                Set NRTItem = .CreateRichTextItem("Attachment")
                NRTItem.EmbedObject 1454, "", Cells(r, "E").Value
            Else
                MsgBox "File " & Cells(r, "E").Value & " doesn't exist so can't attach it to email."
            End If
            
            .SaveMessageOnSend = True
            .send False
        End With
    Next

    Set NSession = Nothing
    Set NDb = Nothing
    Set NDocument = Nothing
    Set NRTItem = Nothing

End Sub

Many thanks
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Having trouble getting the example file to convert so I can attach a screen shot. Columns in the code explain the set up of the spread sheet I use. One option is to read multiple file names and send to one recipient email. The other option is one recipients email address and one folder path.

Hope you can help without the attachment.

Thanks
 
Upvote 0

Forum statistics

Threads
1,216,084
Messages
6,128,724
Members
449,465
Latest member
TAKLAM

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top