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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email from continuous form

Status
Not open for further replies.

neilmcdonald

Technical User
Aug 16, 2002
53
Hi,

I have a continuous form based on a query. The form shows outstanding jobs, and allows the user to allocate an engineer to each job.

Once all the jobs have been allocated, I would like the user to click a single button that will send an email for each job, to the relevant engineer.

I have created a report, which should form the content of the email.

I'm using access 2003 & outlook 2003.

Can anybody help me with this?

Thanks,

Neil
 
Here are some notes.
Code:
Const ForReading = 1, ForWriting = 2, ForAppending = 3

Dim fs, f
Dim RTFBody, strTo
Dim MyApp As New Outlook.Application
Dim MyItem As Outlook.MailItem

'Output the report
DoCmd.OutputTo acOutputReport, "Report1", acFormatRTF, "Report1.rtf"
'The same thing with a query
'DoCmd.OutputTo acOutputQuery, "Query1", acFormatHTML, "Query1.htm"

'To read the file
Set fs = CreateObject("Scripting.FileSystemObject")
'Report
Set f = fs.OpenTextFile("Report1.rtf", ForReading)
'Query
'Set f = fs.OpenTextFile("Query1.htm", ForReading)
RTFBody = f.ReadAll
'Testing
'Debug.Print RTFBody

f.Close

Set MyItem = MyApp.CreateItem(olMailItem)
With MyItem
   .To = "a@b.com"
   .Subject = "Subject"
   .Body = RTFBody
End With
MyItem.Display
End Sub

This has also been metioned in thread181-1091473, thread702-1114426, thread705-1114129
But with slightly different problems in each case.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top