Calling a public function to email a report

O

Opal

I am trying to use the following public function I found at
http://www.fabalou.com/VBandVBA/lotusnotesmail.asp

to email a report via lotus notes but am having trouble
calling the report in access...

Public Sub SendNotesMail(Subject As String, Attachment As String,
Recipient 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
Dim AttachME As Object 'The attachment richtextfile object
Dim Session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object (Attachment)
'Start a session to notes
Set Session = CreateObject("Notes.NotesSession")
'Next line only works with 5.x and above. Replace password with
your password
Session.Initialize("password")
'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 or using above password you can use
other mailboxes.
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName)
- InStr(1, UserName, " "))) & ".nsf"
'Open the mail database in notes
Set Maildb = Session.GETDATABASE("", MailDbName)
If Maildb.ISOPEN = True Then
'Already open for mail
Else
Maildb.OPENMAIL
End If
'Set up the new mail document
Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"
MailDoc.sendto = Recipient
MailDoc.Subject = Subject
MailDoc.Body = BodyText
MailDoc.SAVEMESSAGEONSEND = SaveIt
'Set up the embedded object and attachment and attach it
If Attachment <> "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment,
"Attachment")
MailDoc.CREATERICHTEXTITEM ("Attachment")
End If
'Send the document
MailDoc.PostedDate=Now() 'Gets the mail to appear in the sent
items folder
MailDoc.SEND 0, Recipient
'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing
End Sub

I have successfully gotten the function to work and emailed an excel
spreadsheet
but cannot figure out how to point to the report in access. Does
anyone have any
advice?
 
D

Daniel Pineault

You will have to export/save the report as an external file and then send it
as an attachment, just like the excel file.

You could use Lebans ReporttoPdf

http://www.lebans.com/reporttopdf.htm

to generate a pdf file and email that

OR you could use access' build in snap file and email that, but the person
at the other end would need a snapshot viewer so I would priviledge the PDF
option.
--
Hope this helps,

Daniel Pineault
For Access Tips and Examples: http://www.cardaconsultants.com/en/msaccess.php
If this post was helpful, please rate it by using the vote buttons.
 
O

Opal

You will have to export/save the report as an external file and then send it
as an attachment, just like the excel file.

You could use Lebans ReporttoPdf

http://www.lebans.com/reporttopdf.htm

to generate a pdf file and email that

OR you could use access' build in snap file and email that, but the person
at the other end would need a snapshot viewer so I would priviledge the PDF
option.
--
Hope this helps,

Daniel Pineault
For Access Tips and Examples:http://www.cardaconsultants.com/en/msaccess.php
If this post was helpful, please rate it by using the vote buttons.








- Show quoted text -

Thank you, Daniel.....

Just a couple of questions, though..... The function I am using will
turn the attachment into a .rtf format so it can be viewed on
blackberries...
it seems like a bit of a waste to turn it into a .pdf and then
into .rtf

I also want the whole process invisible to the user....I wonder if I
shouldn't
just export to excel and then email in .rtf.....
 
R

Rick A.B.

Opal,

Not real familar with Lotus notes but if Lotus notes is your default
mail client then you should be able to use the sendobject cmd to do
what you want. Look it up in the help or post back here if you have
more questions.

Rick
 
O

Opal

Opal,

Not real familar with Lotus notes but if Lotus notes is your default
mail client then you should be able to use the sendobject cmd to do
what you want.  Look it up in the help or post back here if you have
more questions.

Rick

Thanks, Rick. I have used the sendobject command and it
works for Lotus notes, but I am trying to get something that works
at the push of the button and is invisible to the user. The above
function will do that, but I still need to figure out how to point
it to the report only.
 
O

Opal

Thanks, Rick.  I have used the sendobject command and it
works for Lotus notes, but I am trying to get something that works
at the push of the button and is invisible to the user.  The above
function will do that, but I still need to figure out how to point
it to the report only.

I figured out a work around.... I am using the following:

DoCmd.OutputTo acOutputReport, "rptMyReport", _
acFormatRTF, "C:\MyReport.rtf", False

and then calling my subroutine pointing to the file in C:\
 

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