This is a discussion on Access 2007 form to email body within the Microsoft Access forums, part of the Question Forums category; I am trying to get a HTML form pasted into the body of an email that the user upon selecting ...
I am trying to get a HTML form pasted into the body of an email that the user upon selecting reply can then fill out the form and then select send when they have completed the form, like the "Create Email" function in Access 2007.
I been trying to manipulte this code as a starting point:
Do I need to change "test" in this part .HTMLBody = test ?
***Send an HTML e-mail from Access:*** within the e-mail body and not just as an Attachment.
First Export one of your talble (small one) as HTML call it test.HTM and save it on your desktop.
Ensure you got the Ms Office Outlook object library selected in Tool>reference
then create a command button in a form and do the following:
Private Sub Command0_Click()
Open "C:\Documents and Settings\user\Desktop\TEST.HTM" For Input As #20
Do Until EOF(20)
Line Input #20, Temp
test = test & Temp & vbCrLf
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("email@example.com")
objOutlookRecip.Type = olTo
' Set the Subject, Body, and Importance of the message.
.BodyFormat = olFormatHTML
.Subject = "This is an Automation test with Microsoft Outlook"
.HTMLBody = test
.Importance = olImportanceHigh 'High importance
' Add attachments to the message.
If Not IsMissing("C:\Documents and Settings\user\Desktop\TEST.HTM") Then
Set objOutlookAttach = .Attachments.Add("C:\Documents and Settings\user\Desktop\TEST.HTM")
' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
' Should we display the message before sending?
'If DisplayMsg Then
Set objOutlook = Nothing
Any insite would be greatly apperciated!