Sending Lotus Notes e-mail from Access

M

Mark Kovach

I am using the code below to send e-mails from Access
through Lotus Notes. This code works great to send an e-
mail and attach a file to it. My problem is that I need
to send the e-mail and attach a report or query to it.
Everything I have found on the web only talks about
attaching a file from outside of Access to the e-mail.
How do I attach a report or query to the e-mail that I am
sending??

Thanks very much for your help.


Sub TestEmail()

Dim objNotesSession As Object
Dim objNotesDatabase As Object
Dim objNotesDocument As Object
Dim strText As String
Dim strMsg As String
Dim strRecipient As String

Dim objAttach As Object
Dim objEmbed As Object
Dim arrRecipient(20) As String

Set objNotesSession = CreateObject("Notes.Notessession")
Set objNotesDatabase = objNotesSession.GETDATABASE("", "")
Call objNotesDatabase.OPENMAIL

Set objNotesDocument = objNotesDatabase.CREATEDOCUMENT
strText = "Body text of message"

arrRecipient(0) = "(e-mail address removed)"
arrRecipient(1) = "(e-mail address removed)"

Call objNotesDocument.REPLACEITEMVALUE("SendTo",
arrRecipient)
Call objNotesDocument.REPLACEITEMVALUE("Subject", "Access
Message")
Call objNotesDocument.REPLACEITEMVALUE("Body", strText)

Set objAttach = objNotesDocument.CREATERICHTEXTITEM
("Attachment")
Set objEmbed = objAttach.EMBEDOBJECT
(1454, "", "c:\cash.bat", "Attachment")

Call objNotesDocument.SEND(False)
Set objNotesSession = Nothing

End Sub
 
P

Peter Russell

Mark said:
I am using the code below to send e-mails from Access
through Lotus Notes. This code works great to send an e-
mail and attach a file to it. My problem is that I need
to send the e-mail and attach a report or query to it.
Everything I have found on the web only talks about
attaching a file from outside of Access to the e-mail.
How do I attach a report or query to the e-mail that I am
sending??

Are you trying to send the query and report objects from the database
window (the 'definitions') or are you trying to send the OUTPUT of the
query or report?

You can't send the objects as such unless you create an mdb file
containing them, and send the mdb file. However for the query you could
extract and send the SQL string.

To send the output of the query you would first have to export it to a
file (Excel, or Text file, for example), or paste it into Word. Then send
the file.

A report has no existence outside of Access so to send a report you would
have to convert it to a different format such as a snapshot file - which
is a standard Access feature- or pdf file for which you would need some
extra software.

Regards

Peter Russell
 
M

Mark Kovach

I need to send the output of the report or query. I was
able to do this with the SendObject command with Outlook
Express. But now I need to be able to do it through
Lotus Notes.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top