I'm tryng to send a form using access vba.
i have an outlook form put value on fields that comes from my database then send the form.
the problem is when i received the email..the form fields/controls has no value.
here's my sample code.have just put some string on it not the actual records.
VB Code:
Sub Transfer_ToMail() Dim oApp As Outlook.Application Dim oMsg As Outlook.MailItem Dim oInspector As Outlook.Inspector Dim oPages As Outlook.Pages Dim oPage As Object Dim oControls As Object Dim oControl As Object Set oApp = New Outlook.Application Set oMsg = oApp.CreateItemFromTemplate("C:\Template\FORM_TEMP.oft") If Not oMsg Is Nothing Then Set oInspector = oMsg.GetInspector Set oPages = oInspector.ModifiedFormPages Set oPage = oPages("Email Notification") Set oControls = oPage.Controls Set oControl = oControls("FIELDNAME1") oControl.Value = "AAA-AA" Set oControl = oControls("FIELDNAME2") oControl.Value = "COMPANY" 'oMsg.Display vbModal oMsg.To = "Gates, Bill oMsg.Send Else MsgBox "Couldnt find your template!" End If Set Inspector = Nothing Set Pages = Nothing Set Page = Nothing Set Controls = Nothing Set Control = Nothing Set oMsg = Nothing oApp.Quit Set oApp = Nothing End Sub





Reply With Quote