e-mailing access reports with lotus notes (1 Viewer)

Matt Gilbert

New member
Local time
Today, 19:33
Joined
Oct 15, 1999
Messages
6
We are trying to email multiple reports using the SendObject action. However, while we have disabled the edit message dialog for each outgoing report, we still get an MS Exchange pop-up screen requesting which email profile to use. We have tried setting up only one email profile but it still comes up every time we send an email (boring if you have 200 to send!). Please HELP !
 

Ed

New member
Local time
Today, 19:33
Joined
Oct 10, 1999
Messages
5
I don't know about MS Exchange but on MS Outlook if you go in the option or préférences menu you can oncheck the option that prompt's you for a profil every time you enter into Ms Outlook.
ED
 

Matt Gilbert

New member
Local time
Today, 19:33
Joined
Oct 15, 1999
Messages
6
We already tried this! No luck however. Anymore ideas?
 

chenn

Registered User.
Local time
Today, 19:33
Joined
Apr 19, 2002
Messages
69
Go to Internet Explorer...

Tools - Internet Options - Programs tab -

Select Lotus Notes as the email program.

This will allow your sendObject to work. However if you are sending 200 items you should put it into a loop. I do this with several databases and it works very well. Let me know if you still need assistance.
 

CutAndPaste

Registered User.
Local time
Today, 19:33
Joined
Jul 16, 2001
Messages
60
Can't get my email reports to work

Chenn,

You say you've got Email reports working, I've tried using several bits of code found here and on other forums but can't get it to work.

I'm using Access 2k. I get a message saying "Error 13 Type Mismatch" Any chance of seeing if I'm doing something wrong in my code? (or posting your code?)

===Code Start===

Private Sub Command9_Click()
Dim db As Database
Dim rst As Recordset
Dim strEmail As String

Set db = CurrentDb
Set rst = db.OpenRecordset("tblEmailList") 'Table holding email Info

rst.MoveFirst
Do Until rst.EOF
strEmail = rst!Email 'Name of Field holding Email Address
Me!txtDisplayCompanyID = rst!txtCompanyID 'Name of field on form with ID or Name
DoCmd.SendObject acSendReport, "rptMyReportName", acFormatRTF, strEmail, , , "MyEmail Subject", "My email Message Body.", False
rst.MoveNext
Loop
End Sub
==End Code===

tx
 

chenn

Registered User.
Local time
Today, 19:33
Joined
Apr 19, 2002
Messages
69
Lotus Notes Automation Code

CutAndPaste,

Type mismatch is when you are trying to put one type of value into a place where Access is expecting a different type. For example, putting a string value into an integer field causes error 13, type mismatch. I would bet that this is the line causing the problem: Me!txtDisplayCompanyID = rst!txtCompanyID but I really don't know without seeing your form and your table. I would post my code, however I don't do it this way.

The docmd works well for one email; however, to send multiple emails (which I frequently do) I use lotus notes automation. I included my code below, hopefully you are able to use it with only minor Tweeking.

There are four subs/functions. The first one is unique to each email function and the other four are part of my "Mail Tools" module. I use these in every database and every email function I use.

I also attached a file with the functions (may be a little easier to read) .Reply if you are still having problems, or you can email me directly.

Have fun.

'*************************************

Option Compare Database
Option Explicit

Public mobjDB As Object

Public Sub SEND_EMAILS()

'open the session with the lotus notes server
'this sub will output a report as a file
'attach the file and add the predetermined subject and body
'delete the file that was output
'close the session with the server

If OPEN_SESSION Then

'output report to text file on C:\
DoCmd.OutputTo acOutputReport, "My Report", acFormatRTF, "C:\My File Name", False

'put your do loop here

'reference the email report sub to mail the file
If EMAIL_REPORT("JoeSmith@AOL.com", "My Email Body", "My Subject Line", "C:\My File Name") = True Then
MsgBox "Message Sent"
Else
'error in email module
End If

'end your loop here

'delete the file
Kill ("C:\My File Name")

'call the close session sub to destroy the objects
CLOSE_SESSION

Else
'session not opened properly
End If

End Sub

Public Function OPEN_SESSION() As Boolean

Dim objSession As Object
Dim strServer As String
Dim strMailFile As String

'lotus notes must be open for module to work correctly
If MsgBox("Do you have lotus notes running?", vbCritical + vbYesNo, "Warning!") = vbYes Then
'this code must be left out of the loop so that only one session is started
Set objSession = CreateObject("Notes.NOTESSESSION")

strServer = objSession.GETENVIRONMENTSTRING("mailserver", True)
strMailFile = objSession.GETENVIRONMENTSTRING("mailfile", True)

Set mobjDB = objSession.GETDATABASE(strServer, strMailFile)

OPEN_SESSION = True
Else
MsgBox "Please start Lotus Notes and try again.", vbOKOnly, "Emails"
OPEN_SESSION = False
End If

End Function

Public Function EMAIL_REPORT(strSendTo As String, strBody As String, strSubject As String, Optional strFile As String) As Boolean
On Error GoTo EmailReport_Err

Dim objDoc As Object
Dim objRichTextAttach As Object
Dim objRichTextItem As Object
Dim objAttachment As Object

Const NOTES_RECIPIENTS = ""
Const NOTES_REPORTS_ADMIN_USER = ""
Const NOTES_MAIL_FILE = "C:\Email.txt"

Set objDoc = mobjDB.CREATEDOCUMENT
Set objRichTextAttach = objDoc.CREATERICHTEXTITEM("File")
Set objRichTextItem = objDoc.CREATERICHTEXTITEM(objDoc, "Body")

If strFile <> "" Then
Set objAttachment = objRichTextAttach.EMBEDOBJECT(1454, "", strFile)
End If

'set up the email to be sent
objRichTextItem.AppendText strBody
objDoc.REPLACEITEMVALUE "SendTo", strSendTo
objDoc.REPLACEITEMVALUE "Subject", strSubject

objDoc.SaveMessageOnSend = True 'send E-mail
objDoc.SEND False 'false for do not attach a form

EMAIL_REPORT = True

Exit_Here:
Set objAttachment = Nothing
Set objDoc = Nothing
Set objRichTextAttach = Nothing
Set objRichTextItem = Nothing
Exit Function

EmailReport_Err:
EMAIL_REPORT = False
Resume Exit_Here

End Function

Public Sub CLOSE_SESSION()

Set mobjDB = Nothing

End Sub
 

Attachments

  • lotus notes automation.zip
    2.8 KB · Views: 428

TheTrainMan

Registered User.
Local time
Today, 19:33
Joined
Dec 11, 2002
Messages
18
I know this thread is from a long time ago, but the code from it is great!!!... but I've got a few problems!

Whenever I use the functions, the email appears as an unsent&unread draft email in notes... is this just because I'm using an ancient version of notes (3.something - it's on my work comp!) or is there a way to ensure that it ends up as showing up being as a sent email?

I know perhaps I'm being a bit picky, but since it's for business use and not for personal use, it might make a difference if the recipients claim not to have got the emails!!!

Also, is there a way to get a receipt sent back as well???
 

chenn

Registered User.
Local time
Today, 19:33
Joined
Apr 19, 2002
Messages
69
First, I'm glad you liked the code. I've been using it for about a year and a half and think I have worked out most of the bugs.

I think that the version of lotus you are using is causing you problems. I use R5 and everything hits my sent items (but that took awhile to get to work). I remember that it had something to do with this line of code:

objDoc.SaveMessageOnSend = True 'send E-mail

I imagine that it would take some time to figure out the slight differences in the different versions. A work around may be that if the email function returns true, you could store the file name, email address, and time in a table.

As far as a return receipt, I don't know if that is possible. I know that with Lotus, you have to specify on each email whether or not you want a return.
 

Users who are viewing this thread

Top Bottom