Emailing in Lotus Notes

Myriad_Rocker

Questioning Reality
Local time
Yesterday, 18:27
Joined
Mar 26, 2004
Messages
166
Hey everyone! Here's the thing....I have some code below that works GREAT for emailing a canned message to someone over Lotus Notes....but there are a couple of problems...

1. It doesn't email to multiple people. I've tried unsuccessfully.
2. I need to attach a report that I have generated in Access. How do I do that?

Here's the code:

Function SendLotus()
Dim S As Object
Dim db As Object
Dim doc As Object
Dim rtItem As Object
Dim LIST1 As String 'add a greater range to send more
Dim Server As String, Database As String
Dim strError As String

LIST1 = ("Email@SomeCompany.com")

' start up Lotus Notes and get object handle
Set S = CreateObject("Notes.NotesSession")
Server = S.GETENVIRONMENTSTRING("MailServer", True)
Database = S.GETENVIRONMENTSTRING("MailFile", True)
Set db = S.GETDATABASE(Server, Database)

On Error GoTo ErrorLogon
' See if user is logged on yet;
' if not, the error handler will
' kick in!
Set doc = db.CREATEDOCUMENT
On Error GoTo 0

doc.Form = "Memo"
doc.Importance = "1" '(WHERE 1=URGENT, 2= NORMAL, 3=FYI)

'Send an EMail to
doc.SENDTO = (LIST1)
'SENDS A RETURN RECIEPT
'doc.RETURNRECIEPT = "1"
doc.Subject = "Test"

' this will build the text part of your mail message

Set rtItem = doc.CREATERICHTEXTITEM("Body")
Call rtItem.APPENDTEXT("This email was generated automatically" & vbCrLf & "This is a new line")
Call rtItem.ADDNEWLINE(1)
'doc.SaveMessageOnSend = True 'to Save in Sent Folder
Call doc.send(False) 'Make sure this parameter stays false

' set all object handles to nothing to release memory
Set doc = Nothing
Set db = Nothing
Set S = Nothing
Set rtItem = Nothing


'MsgBox "Mail has been sent!", vbInformation

Exit Function

ErrorLogon:
If Err.Number = 7063 Then
MsgBox "Please login to Lotus Notes first!", vbCritical
Set doc = Nothing
Set db = Nothing
Set S = Nothing
Set rtItem = Nothing

Exit Function
Else
strError = "There was an error in your system:" & vbCrLf
strError = strError & "Err. Number: " & Err.Number & vbCrLf
strError = strError & "Description: " & Err.Description
MsgBox strError, vbCritical
Set doc = Nothing
Set db = Nothing
Set S = Nothing
Set rtItem = Nothing

Exit Function
End If

End Function
 
Sorry I can't help you but I am interested in the code. Can you tell me where you found it?
 
Somewhere on here...I don't recall the thread.
 
Isn't it just a case of changing this line:
LIST1 = ("Email@SomeCompany.com")
to
LIST1 = ("Email@SomeCompany.com, email2@another.com, email3@endoftime.net")

You might need to use ; and not , to seperate (or maybe some other character)

If that doesn't work, then cheat:) and loop through an array of the address sending to each in turn.

As for attachements not sure, does the intellisense for 'doc' and 'rtitem' not give any clues?
 

Users who are viewing this thread

Back
Top Bottom