Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lotus Notes Help

Status
Not open for further replies.

sdavid74

Technical User
May 28, 2002
21
US
I have looked over the history of this forum, but I wasn't able to glean the information that I needed. I have a db with contacts to whom I would like to be able to send emails (both individually and group). I view all the contact info on a form where I would like to have a button or two that opens up a new email and has either the address of one contact or of all 50, depending on what I need to do. Our company uses Lotus Notes 5.0. Can anyone help me with this?
 
I have some code on either this forum or forum705 that allows you to send mails from Lotus notes.
Search by my nick and you should find it (it's 1am here so I am too tired to do it myself!)
If you can't find it, let me know & I'll dig it out when I get to work on Monday.

Let me know how you get on.

Ben ----------------------------------------
Ben O'Hara
----------------------------------------
 
Ben, I have not been able to find that code in this forum or Forum705. I have searched by your handle in both places. Is there somewhere else I could look for it?
 
I can't find it either! No matter here is the code.
Copy it all into a new module:

Call it like it says:
SendNotesMail "Subject Here","C:\File.txt","bpo@robotparade.co.uk","","Hi Ben",true

HTH

ben




Sub SendNotesMail(Subject As String, Attachment As String, Recipient As Variant, cc As String, BodyText As String, SaveIt As Boolean)

'Set up the objects required for Automation into lotus notes
Dim MailDb As Object 'The mail database
Dim UserName As String 'The current users notes name
Dim MailDbName As String 'THe current users notes mail database name
Dim MailDoc As Object 'The mail document itself NotesDocument
Dim MailDoc2 As Object
Dim AttachME As Object 'The attachment richtextfile object
Dim session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object (Attachment)
Dim CurrentDatabase As String
Dim NotesSS As Object
Dim NotesDb As Object

On Error GoTo Errshow:

Set NotesSS = CreateObject("Notes.NotesSession")
With NotesSS
Set NotesDb = .GETDATABASE("WAKEAM3/WYP", "mail\721116.nsf")
End With

With NotesDb
'Start a session to notes
Set session = CreateObject("Notes.NotesSession")
'Get the sessions username and then calculate the mail file name
'You may or may not need this as for MailDBname with some systems you
'can pass an empty string
UserName = session.UserName
MailDbName = NotesDb.FileName

Set MailDb = session.GETDATABASE("", MailDbName)

If Not (MailDb.ISOPEN) = True Then MailDb.OPENMAIL

'Set up the new mail document
Set MailDoc = MailDb.CREATEDOCUMENT
With MailDoc
.Form = "Memo"
.sendto = Recipient
.CopyTo = cc
.Subject = Subject
.Body = BodyText
.SAVEMESSAGEONSEND = SaveIt
End With
'Set up the embedded object and attachment and attach it
If Attachment <> &quot;&quot; Then
Set AttachME = MailDoc.CREATERICHTEXTITEM(&quot;Attachment&quot;)
Set EmbedObj = AttachME.EMBEDOBJECT(1454, &quot;&quot;, Attachment, &quot;Attachment&quot;)
MailDoc.CREATERICHTEXTITEM (&quot;Attachment&quot;)
End If

End With

'Send the document
MailDoc.SEND 1, Recipient
Cleanup:

Set MailDb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set session = Nothing
Set EmbedObj = Nothing

Exit Sub

Errshow:
If Err.Number = 7063 Then
MsgBox &quot;You have not logged onto your notes database. Please log on and try to send again.&quot;
Else
MsgBox (Err.Description)
End If
GoTo Cleanup

End Sub
----------------------------------------
Ben O'Hara
----------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top