M
Mary
I have created an html form that enduser will be using . They will fill out
the form then submit the form. I will received the form via outlook. The
problem i am facing is importing the content of the email into access. i have
search and found this code. I think this code works. but i am get a compile
error: sub or function not defined . on this line
UserName = ExtractDetail(rstExchange!Contents, "userName=")
Below is the code and the link for the code is
http://www.vb123.com/toolshed/99docs/automated_email.htm
ANY HELP WILL BE GREATLY APPRECIATED. THANKS IN ADVANCE
--------------------------------------------------------------------------------------------
Private Sub cmdUserDetails_Click()
' Loop through the Exchange tables and decode the
' users web response into a useable Access table
Dim dbs As Database
Dim rstExchange As Recordset, rstUsers As Recordset
Dim UserEmail As Variant, postIt As Integer
Dim UserName As Variant, UserCompany As Variant
Dim UserCountry As Variant, UserComments As Variant
Dim AccessVersion As Variant, EmailDownload As Variant
' Set the current database and define the 2 recordsets
Set dbs = CurrentDb
Set rstExchange = dbs.OpenRecordset("SoftwareDownloads")
Set rstUsers = dbs.OpenRecordset("SoftwareUsers", DB_OPEN_TABLE)
rstExchange.MoveFirst
Do Until rstExchange.EOF ' Begin loop.
' Extract the users details from the Web Form email
UserName = ExtractDetail(rstExchange!Contents, "userName=")
UserEmail = ExtractDetail(rstExchange!Contents, "userEmail=")
UserCompany = ExtractDetail(rstExchange!Contents, "userCompany=")
UserCountry = ExtractDetail(rstExchange!Contents, "userCountry=")
UserComments = ExtractDetail(rstExchange!Contents, "userComments=")
If Len(UserEmail) > 0 And InStr(UserEmail, "@") Then
' Confirm that the entered detail is legitimate and post i
postIt = MsgBox(UserName & " " & UserEmail & " " & UserCompany & " " &
UserCountry & " " & AccessVersion & " " & UserComments, vbYesNoCancel, "Post
The Following")
If postIt = vbYes Then
On Error Resume Next
rstUsers.AddNew ' Create new record.
rstUsers("userName") = UserName
rstUsers("userEmail") = UserEmail
rstUsers("userCompany") = UserCompany
rstUsers("userCountry") = UserCountry
If Len(UserComments) > 0 Then
rstUsers("userComments") = UserComments
End If
rstUsers.Update ' Save changes.
On Error GoTo errCmdUserDetails
Else
If postIt = vbCancel Then
GoTo exitCmdUserDetails
End If
End If
End If
rstExchange.MoveNext ' Locate next record.
Loop ' End of loop.
exitCmdUserDetails:
rstExchange.Close ' Close table.
rstUsers.Close
Set dbs = Nothing
Exit Sub
errCmdUserDetails:
Error Err.Description
GoTo exitCmdUserDetails
End Sub
the form then submit the form. I will received the form via outlook. The
problem i am facing is importing the content of the email into access. i have
search and found this code. I think this code works. but i am get a compile
error: sub or function not defined . on this line
UserName = ExtractDetail(rstExchange!Contents, "userName=")
Below is the code and the link for the code is
http://www.vb123.com/toolshed/99docs/automated_email.htm
ANY HELP WILL BE GREATLY APPRECIATED. THANKS IN ADVANCE
--------------------------------------------------------------------------------------------
Private Sub cmdUserDetails_Click()
' Loop through the Exchange tables and decode the
' users web response into a useable Access table
Dim dbs As Database
Dim rstExchange As Recordset, rstUsers As Recordset
Dim UserEmail As Variant, postIt As Integer
Dim UserName As Variant, UserCompany As Variant
Dim UserCountry As Variant, UserComments As Variant
Dim AccessVersion As Variant, EmailDownload As Variant
' Set the current database and define the 2 recordsets
Set dbs = CurrentDb
Set rstExchange = dbs.OpenRecordset("SoftwareDownloads")
Set rstUsers = dbs.OpenRecordset("SoftwareUsers", DB_OPEN_TABLE)
rstExchange.MoveFirst
Do Until rstExchange.EOF ' Begin loop.
' Extract the users details from the Web Form email
UserName = ExtractDetail(rstExchange!Contents, "userName=")
UserEmail = ExtractDetail(rstExchange!Contents, "userEmail=")
UserCompany = ExtractDetail(rstExchange!Contents, "userCompany=")
UserCountry = ExtractDetail(rstExchange!Contents, "userCountry=")
UserComments = ExtractDetail(rstExchange!Contents, "userComments=")
If Len(UserEmail) > 0 And InStr(UserEmail, "@") Then
' Confirm that the entered detail is legitimate and post i
postIt = MsgBox(UserName & " " & UserEmail & " " & UserCompany & " " &
UserCountry & " " & AccessVersion & " " & UserComments, vbYesNoCancel, "Post
The Following")
If postIt = vbYes Then
On Error Resume Next
rstUsers.AddNew ' Create new record.
rstUsers("userName") = UserName
rstUsers("userEmail") = UserEmail
rstUsers("userCompany") = UserCompany
rstUsers("userCountry") = UserCountry
If Len(UserComments) > 0 Then
rstUsers("userComments") = UserComments
End If
rstUsers.Update ' Save changes.
On Error GoTo errCmdUserDetails
Else
If postIt = vbCancel Then
GoTo exitCmdUserDetails
End If
End If
End If
rstExchange.MoveNext ' Locate next record.
Loop ' End of loop.
exitCmdUserDetails:
rstExchange.Close ' Close table.
rstUsers.Close
Set dbs = Nothing
Exit Sub
errCmdUserDetails:
Error Err.Description
GoTo exitCmdUserDetails
End Sub