News, links, downloads, tips and tricks on Microsoft Access and related

About Me Search
Name:Alex Dybenko

Location:Moscow, Russia

Monday, January 04, 2010

How to send email with Lotus Notes

It is pretty easy if you have VBA routine. Link from IBM site will give you one. And here one from my application:

Public Function SendNotesMail(strTo As String, _
    strSubject As String, strBody As String, _
    strFileName As String, ParamArray strFiles()) As Boolean
    'SendNotesMail "", _
        "subj", "some body", "c:\filename.txt"
    Dim doc As Object   'Lotus NOtes Document
    Dim rtitem As Object '
    Dim Body2 As Object
    Dim ws As Object    'Lotus Notes Workspace
    Dim oSess As Object 'Lotus Notes Session
    Dim oDB As Object   'Lotus Notes Database
    Dim X As Integer    'Counter
    Set oSess = CreateObject("Notes.NotesSession")
    'access the logged on users mailbox
    Set oDB = oSess.GETDATABASE("", "")
    'create a new document as add text
    Set rtitem = doc.CREATERICHTEXTITEM("Body")
    doc.sendto = strTo
    'doc.CopyTo = CCToAdr
    'doc.BlindCopyTo = BCCToAdr
    doc.Subject = strSubject
    doc.Body = strBody & vbCrLf & vbCrLf
    'attach files
    If strFileName <> "" Then
        Set Body2 = rtitem.EMBEDOBJECT(1454, "", strFileName)
        If UBound(strFiles) > -1 Then
            For X = 0 To UBound(strFiles)
                Set Body2 = rtitem.EMBEDOBJECT(1454, "", strFiles(X))
            Next X
        End If
    End If
    doc.SEND False
    SendNotesMail = True
End Function

Labels: ,


Anonymous Roopesh said...

hi Alex,

it seems awesome. Is there any possibikity to do the same for


7:06 AM  
Blogger Alex Dybenko said...

there are plenty of samples, see:

and for advanced:

5:05 PM  
Anonymous Anonymous said...

Hi Alex,

Thank you very much!
I need to send 500 different emails and 500 different attachments. Is there a way to do this?

12:39 PM  
Blogger Alex Dybenko said...

yes, you can send 500 emails using this method

12:48 PM  
Blogger Jack said...

Great help to send bulk emails using Lotus Notes. It seems me the right place to share that Lotus Notes save all our data in NSF file. This NSF file sometimes gets corrupt or becomes inaccessible due to various reasons. But IBM provides no tool that helps us in recovering NSF file so we have to rely on third party nsf file recovery tools.

10:07 AM  
Anonymous Anonymous said...

Where can I use this code, sorry i am a newbie.

8:53 AM  
Anonymous Anonymous said...

I've tried strings, arrays but I can't get the Public Function SendNotesMail to cc more than two people at one time. I've tried these for cc:
Best I got are the first two get sent. What's up?

2:37 AM  
Blogger Alex Dybenko said...

try this:


9:16 AM  
Blogger MarkPerkin2 said...

NSF Repair Kit
A must-have Lotus Notes NSF repair utility for home users and professionals dealing with NSF file corruption on a regular basis.

As it works, is described here:

If it doesn't work, then look here:

11:14 AM  

Post a Comment

<< Home