Lotus Notes vs VBA offline e-mail sending

pernicek used Ask the Experts™
Hi @ all,

I'm developing solution for my wordwide partner from switzerland. It sending e-mail from word, excel via Lotus Notes Automation classes, VB for applications.Everything works well, but we cannot send e-mails offline.

We are using mail.box file of user and the document.save method. It appears good, we can see the mail in items to sent via Lotus Notes GUI, but when user synchronize, it shows general error with no other description. I have attached source code.

I have attached module LotusNotes.bas, which is actually used for sending mails. There are used some function from other modules, such as recipient detection & else, which are not directly participating on described error.

I can send whole (.docx) file if required.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Do these people have an offline replica of their mail file?  If so what I do is this, it will end up in the mail.box anyway.

Sub SendNotesEmail(sendto As String, subject As String, body As String)

Rem VBA Macros written by Steve Knight Sept. 2008 to interface
Rem with Notes servers for sending email.  stephen DOT knight {AT} dragon {DASH} it.co.uk
Rem General email through Notes routine.  Uses arguments for what to send and where to send
Rem Body has this Excel sheet attached to it and username of user sending added to bottom

Rem "Declare notes objects"
Dim notesdb As Object
Dim notesdoc As Object
Dim notesrtf As Object
Dim notessession As Object

Rem "Connect to mail database"
Set notessession = CreateObject("Notes.Notessession")
Set notesdb = notessession.getdatabase("", "")
Call notesdb.OPENMAIL

Rem "Make new mail message"
Set notesdoc = notesdb.CREATEDOCUMENT
With notesdoc
    .replaceitemvalue "Form", "Memo"
    .replaceitemvalue "Sendto", sendto
    .replaceitemvalue "Copyto", notessession.UserName
    .replaceitemvalue "Subject", subject
    '.REPLACEITEMVALUE "BlindCopyto", "And Blind copy"
    Rem "Setup Body of message"
    Set notesrtf = notesdoc.CREATERICHTEXTITEM("body")
        notesrtf.AppendText body
        notesrtf.ADDNEWLINE 2
        Call notesrtf.EMBEDOBJECT(1454, "", ActiveWorkbook.Path & "\" & ActiveWorkbook.Name)
        notesrtf.ADDNEWLINE 2
        notesrtf.AppendText "Userlogin: " & Environ$("USERNAME")
        notesrtf.ADDNEWLINE 1
        notesrtf.AppendText "Notes name : " & notessession.commonusername

    Rem "Send Message"
    .Send (False)
End With

Rem "Clean up objects"

Set notessession = Nothing
Set notesdb = Nothing
Set notesdoc = Nothing
Set notesrtf = Nothing

End Sub

Open in new window

tip: send a memo from the user, and check which other field need to be set. I am guessing that the replicator does not like mail without a sender name.

You can get more information on the fields you find in the example mail.  This webiste describes Calendaring and scheduling which is an extension of the Mail functionality.  So it contains a little too much info, but will help you along deciding what to put in the fields you do find in your own example mail.

Also, it would be helpful if you included the error message you are receiving.


At dragon-it,

as you can see in attached bas file, we are using the same way to connect database.

In first version (attached is third) we had the same way as you, to send mail both online and offline.

But when you were offline, an error was occured: database object was empty, so we decided to change way and store mails directly to mail.box file, but lotus not send them when synchronize.

That's the point of problem.

At larsberntrop: Thanks for tip, we believe, that we are missing some items (like senders name) in offliíne version. I will try you solution and let you know.
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

Ok, the part I looked at you were getting the mail server and name from the notes.ini file?  This used OpenMail which for me works regardless of offline or not when the user had local mail file but maybe not in your environment?



Only some users have local replica, but i feel (tested by other person) that this results in described exception.
Sjef BosmanGroupware Consultant

If you don't have a local replica, mail replication usually is inactive.

Thanks for selecting my answer, though not for the "B" grade, I hasn't seen the last few comments there at the time.

Frankly if there mail clients are setup with locations that the user uses such as the default just "Island" and "Office" pointing to a server mail file then there is no local mail facility.  There may be a mail.box or local mail replica but that is irrelevant as nothing specifically does anything with them.

If they have been defined with an "offline mail" and "online mail" location or similar aswell and local sceduled replication is turned on then yes dropping a mail in mail.box while in offline state should send as soon as they replicate or it is scheduled to run.

So mainly it is down to how the client is configured, but using notesdb.openmail rather than reading notes.ini should work.  If they are truly offline and no local replica / replication then I would suggest storing a transaction in your applications perhaps which could be retried later.

Better though would be to configure the notes clients with local replicas if they are expected to work offline.


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial