Email Report

renenger

Registered User.
Local time
Today, 09:34
Joined
Oct 25, 2002
Messages
117
I have been surfing through all the topics on this subject and can't seem to find the right information. I found a post that demonstrates how to create an email from Access that automatically sends.

This work great for me. The problem I have is that I want to copy and paste information from a word doc into the body fo the email and have it send.

Here is the code I am using below:

Public Sub SendCAReport()

Dim objAttachment As Object
Dim objMailDb As Object
Dim objMailDocument As Object
Dim objEmbedObject As Object
Dim objNotesSession As Object
Dim oDoc As Word.Application
Dim fSaveMailToTheSentFolder As Boolean

fSaveMailToTheSentFolder = True


Dim strMailDbName As String
Dim strMailTitle As String
Dim strLotusNotesUserID As String
Dim strMessage As t
On Error Resume Next

'copy info from Word
Set oDoc = GetObject("C:\CASummary.doc")
oDoc.Documents.Open ("C:\CASummary.doc")
strMessage = oDoc.ActiveDocument.Content

'Start objNotesSession in Lotus Notes
Set objNotesSession = CreateObject("Notes.NotesSession")

'Open the mail database in Lotus Notes
Set objMailDb = objNotesSession.GETDATABASE("", strMailDbName)
objMailDb.OPENMAIL


'Set up the new mail document
strMailTitle = "CA Turn-In Requests"
strLotusNotesUserID = "brenenger@capitalcabinet.com"

Set objMailDocument = objMailDb.CREATEDOCUMENT
objMailDocument.Form = "Memo"
objMailDocument.sendto = strLotusNotesUserID
objMailDocument.Subject = strMailTitle
objMailDocument.Body = strMessage
objMailDocument.SAVEMESSAGEONSEND = fSaveMailToTheSentFolder


'Send the document
objMailDocument.SEND 0, strLotusNotesUserID
oDoc.Documents.Close ("C:\CASummary.doc")

'Clean Up
Set objMailDb = Nothing
Set objMailDocument = Nothing
Set objAttachment = Nothing
Set objNotesSession = Nothing
Set objEmbedObject = Nothing

End Sub


It just sends a blank email.

Any ideas would be GREATLY appreciated.
 
The body of an e-mail can be a text file which you can of course copy and paste into. You will need this extract of code which as you can see I use a Form to hold the body text, then output it as a textfile and then read it back into the e-mail. Good luck
------------------------------------------------------------

DoCmd.OpenForm "F-emailbodytext", , , , , acDialog
'
'Now output the file
DoCmd.OutputTo acReport, "R-emailbodytext", "MS-DOSText(*.txt)", streMailBodyPath, False, "", 0
'
Set fso = New FileSystemObject

' First, we need to know the subject.


BodyFile$ = streMailBodyPath

' Check to make sure the file exists...
If fso.FileExists(BodyFile$) = False Then
MsgBox "The body file isn't where you say it is. " & vbNewLine & vbNewLine & "Quitting...", _
vbCritical, "I Ain't Got No-Body!"
Exit Function
End If

' Since we got a file, we can open it up.
Set MyBody = fso.OpenTextFile(BodyFile, ForReading, False, TristateUseDefault)

'and read it into a variable.
MyBodyText = MyBody.ReadAll

' and close the file.
MyBody.Close
 

Users who are viewing this thread

Back
Top Bottom