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

Send email when user enters data in form 1

Status
Not open for further replies.

mot98

MIS
Jan 25, 2002
647
CA
Hi All,

We have a database that users enter data with a basic form.

I want to send an email out when the user finish entering the data, and hit the submit button.

Does anyone have any code for this?



mot98
[cheers]
"Is it friday yet?"
 
Maybe SendObject or one of the Outlook email FAQs?
 
Okay, I got the e-mail working good when the user inputs the data into the form.

I used the following code:
Code:
Private Sub submit_Click()

Dim bStarted As Boolean
Dim oOutlookApp As Object
Dim oItem As Object
Dim varTo As Variant        '-- Email Address for SendObject
Dim stSubject As String     '-- Subject line of e-mail
Dim stMenu As String        '-- The Menu
Dim stOption As String      '-- The Option
Dim stName As String        '-- Person who requested help
Dim stPlant As String       '-- Plant
Dim stDescription As String '-- Description of Problem


On Error Resume Next

'Get Outlook if it's running
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
   'Outlook wasn't running, start it from code
   Set oOutlookApp = CreateObject("Outlook.Application")
   bStarted = True
End If

' Set Variables
'-- Sets Who created the request
    stName = Me.Contact_Name
    stPlant = Me.Plant
    '-- Sets email address
    varTo = "help@ventra.com"
    
    stSubject = ":: New CMS Issue ::"

    stMenu = Me.Menu
    stOption = Me.Option
    stDescription = Me.Description_of_Problem
    

    stText = "Person Requesting Help:" & stName & Chr$(13) & _
    "Menu Name:" & stMenu & Chr$(13) & _
    "Option Number:" & stOption & Chr$(13) & Chr$(13) & _
    "Description of Problem:" & stDescription & Chr$(13) & Chr$(13) & _
"This is an automated message. Please do not respond to this e-mail."


'Create a new mailitem
Set oItem = oOutlookApp.CreateItem(0)

With oItem
   'Set the recipient for the new email
   .To = "help@****.com"
   'Set the subject
   .Subject = "NEW CMS ISSUE!"
   'Set the message body
   .Body = stText
   .Send
End With

If bStarted Then
   'If we started Outlook from code, then close it
   oOutlookApp.Quit
End If

'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing

End Sub
Is there a way to have this form available to all users even if they don't have access installed on their computers?

Thanks,



mot98
[cheers]
"Is it friday yet?"
 
The runtime version of Access is available in the developer edition.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top