Lotus "Database Not Open Yet"

SpentGeezer

Pure Noobism
Local time
Today, 22:24
Joined
Sep 16, 2010
Messages
258
Greetings, and Merry Christmas to one and all,

I use this Function to send emails through Lotus from Access 2003 Database.

Code:
Public Function NotesMailSend(strRecipient As String, strSubj As String, strBody As String, strAttachment As String)

'StrRecipient is the email address of the recipient
'strSubj is the subject string
'strBody is the body of the email (string)
'strAttachment is a comma delimitered string of the file path of the attahcments

On Error GoTo Err_NotesMailSend

   Dim objNotes As Object
   Dim objNotesDB As Object
   Dim objNotesMailDoc As Object
   Dim attachME As Object
   Dim EmbedObj As Object
   Dim splitTitle() As String

   Set objNotes = GetObject("", "Notes.Notessession")
   Set objNotesDB = objNotes.getdatabase("", "")

   Call objNotesDB.openmail
   Set objNotesMailDoc = objNotesDB.CreateDocument

    'need to create an array for multiple atachments
    If Len(strAttachment) > 0 Then 'if there is an attachment
        splitTitle = Split(strAttachment, ",")
        Dim SplitAttachment() As Variant
        ReDim SplitAttachment(UBound(splitTitle))
        For TitleCount = LBound(splitTitle) To UBound(splitTitle)
            SplitAttachment(TitleCount) = splitTitle(TitleCount)
        Next


        'setup the to, subject and body of the email.
        Call objNotesMailDoc.replaceitemvalue("SendTo", strRecipient)
        Call objNotesMailDoc.replaceitemvalue("Subject", strSubj)
        Call objNotesMailDoc.replaceitemvalue("Body", strBody)

        'attach the single or multiple PDFs
        For TitleCount = LBound(splitTitle) To UBound(splitTitle)
            strAttachment = splitTitle(TitleCount)
 
            If strAttachment <> "" Then
                Set attachME = objNotesMailDoc.CREATERICHTEXTITEM(SplitAttachment(TitleCount))
                Set EmbedObj = attachME.EMBEDOBJECT(1454, "", strAttachment, SplitAttachment(TitleCount))
                'objNotesMailDoc.CREATERICHTEXTITEM ("strAttachment")
                'Set attachME = Nothing
                'Set EmbedObj = Nothing
            End If
        Next
    Else 'if there is no attachment
        Call objNotesMailDoc.replaceitemvalue("SendTo", strRecipient)
        Call objNotesMailDoc.replaceitemvalue("Subject", strSubj)
        Call objNotesMailDoc.replaceitemvalue("Body", strBody)
    End If
    'send the email
    
    'save the sent mail
   objNotesMailDoc.SaveMessageOnSend = True

   Call objNotesMailDoc.Send(False)

   'MsgBox "Mail Sent to " & strRecipient & " OK", vbInformation, "Sender notes-mail..."

   Set objNotes = Nothing

Exit_NotesMailSend:
   Exit Function

Err_NotesMailSend:
    NotesMailSend = "Abort"
    MsgBox Err.Description & "Contact GIS on 694 if problem persists", vbExclamation, "Error"
    Exit Function
   'Resume Exit_NotesMailSend

End Function

THis works on 11 out of 12 user's PCs. One however fails probably 60% of the time with the attached Error message popping up (refer to Error catch in code, gives Err.Description + some of my rubbish. Any Lotus Notes Gurus out there know anything about the .nsf issues?

Thanks,
Spent.
 

Attachments

  • ErrorMessage.JPG
    ErrorMessage.JPG
    10.9 KB · Views: 153

Users who are viewing this thread

Back
Top Bottom