AccessBlog.net

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

About Me Search
Alex
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
    'Usage:
    'SendNotesMail "SteveO@microsoft.com", _
        "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("", "")
    Call oDB.OPENMAIL
 
    'create a new document as add text
    Set doc = oDB.CREATEDOCUMENT
    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.SAVEMESSAGEONSEND = True
    doc.SEND False
 
    SendNotesMail = True
End Function
 
 
 
 

Labels: ,

9 Comments:

Anonymous Roopesh said...

hi Alex,

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

regards,
Roopesh

7:06 AM  
Blogger Alex Dybenko said...

Hi,
there are plenty of samples, see:
http://support.microsoft.com/kb/209948

and for advanced: http://www.outlookcode.com/

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 Jenny Lembert 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:
array("email1@some.com","email2@some.com","email3@some.com")
and
"email1@some.com","email2@some.com","email3@some.com"
Best I got are the first two get sent. What's up?

2:37 AM  
Blogger Alex Dybenko said...

try this:

SendNotesMail("email1@some.com;email2@some.com","Subject"...

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: http://www.nsf.repair/

If it doesn't work, then look here: http://www.filerepairforum.com/forum/other/other-aa/lotus-notes/357-how-to-repair-corrupted-nsf-file-in-lotus-notes

11:14 AM  

Post a Comment

Links to this post:

Create a Link

<< Home