Access 2007 form to email body

L

Legacy 128378

Guest
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
Loop
Close #20


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)

With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("your-email@e-mail.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")
End If

' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next

' Should we display the message before sending?
'If DisplayMsg Then
'.Display
'Else
.Save
.Send
'End If
End With
Set objOutlook = Nothing

End Sub

Any insite would be greatly apperciated!

Thanks!<!-- / message --><!-- sig -->
<!-- / message -->
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,214,551
Messages
6,120,159
Members
448,948
Latest member
spamiki

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top