Email via Lotus Notes

new topic     » topic index » view thread      » older message » newer message

Hi All,
    I am looking for a little help, I would like to be able to send 
email from within an (Windows) Eu program via Lotus Notes, I have some 
VB code that I 'acquired' that is supposed to do just that, but I know 
nothing about VB.
Would someone like to try converting the code below into Eu?

Option Explicit
Dim LNSession As New Domino.NotesSession
Dim LNDatabase As New Domino.NotesDatabase

Dim LNNotesSession As Object
Dim LNNotesDB As Object
Dim LNNotesDoc As Object
Dim Rtfield As Object
Dim Attachment As Object
Dim ErrorMessage  As String
Dim eMailSubject As String
Dim Message As String

Dim NotesInitialized As Boolean
Dim NoFile As Boolean
Dim Bad As Boolean

Dim ToDelFSO As New FileSystemObject
Dim msg As String

Private Sub email()
On Error GoTo SendMailError

'LNSession.Initialize
Const EMBED_ATTACHMENT = 1454  '??
If Not NotesInitialized Then
    Set LNNotesSession = CreateObject("Notes.NotesSession")
        If Err <> 0 Then
            ErrorMessage = "Error during Notes CreateObject - " & 
Str$(Err)
& " - " & Error$
            Exit Sub
        End If
    ' set up new document
    Set LNNotesDB = LNNotesSession.GetDatabase("", "mail.box")
        If Err <> 0 Then
            ErrorMessage = "Error during Notes GetDataBase - " & 
Str$(Err) &
" - " & Error$
            Exit Sub
        End If
    NotesInitialized = True
End If

' create Notes session.  This is only supported by Notes 4.x
' if using Notes 3.x, this will raise an error
OpenCustList
    For gCustListCurrentRecord = 1 To gCustListLastRecord
        Get gCustListFileNum, gCustListCurrentRecord, gCustListRecord
        Set LNNotesDoc = LNNotesDB.CreateDocument
        If Err <> 0 Then
            ErrorMessage = "Error during Notes CreateDocument - " &
Str$(Err) & " - " & Error$
        Exit Sub
        End If
        eMailSubject = "Your Call Units Balance"
        Message = "Dear," & vbCrLf & "Here are the summary on your CU 
for
this Month" & vbCrLf
        ' populate document fields
    'WHAT IF FILES DOESN'T EXISTS????
        Set Rtfield = LNNotesDoc.CreateRichTextItem("Body")
    'Check for the file to attach
        If ToDelFSO.FileExists(FilesPath & "a.txt") Then
            Set Attachment = Rtfield.EmbedObject(EMBED_ATTACHMENT, "",
FilesPath & "a.txt")
        Else
            msg = MsgBox(FilesPath & "a.txt" & "  NOT FOUND / MAIL will 
NOT
be sent : ", vbOKOnly)
            Bad = True
        End If

 If Not Bad Then
            With LNNotesDoc
                .Form = "memo"
                .sendto = " put here the address or a variable with the
address"
                .CopyTo = ""
                .Origin = LNNotesSession.UserName
                .Subject = eMailSubject
                .Body = Message
                .ReturnReceipt = 0
                .Send False
                '.Save True, True
                If Err <> 0 Then
                    ErrorMessage = "Error during Notes SEND - " & 
Str$(Err)
& "" - " & Error$"
                    Exit Sub
                End If
            End With
        Else
            'nothing is sent but bad resetted
            Bad = False
        End If

Set LNNotesDoc = Nothing
Exit Sub
SendMailError:
    If Err <> 0 Then
        ErrorMessage = "Error during Notes SEND - " & Str$(Err) & "" - " 
&
Error$"
    End If
    msg = "error occured while sending to " & gCustListRecord.Cust
    Resume Continue
End Sub

Regards Pete...

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu