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 -->
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 -->