Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Cdosys: Send some fields from form to email

New Here ,
May 05, 2009 May 05, 2009

Copy link to clipboard

Copied

I am going absolutely spare (and my client impatient)

I have a client update form where I need to send some, but not all, fields to an administrator via email.

The from is classic asp and the form is populating an SQL database.

I have forms that send 1 field from a form.

I have forms that send all fields from a form.

But I can not generalize to create a form that allows me to select which field to send.

Does anyone have a code snippet i can model???

This is my starting point which sends all fields.

<%
For Field = 1 to Request.Form.Count - 3
FieldName = Replace(Request.Form.Key(Field),"_"," ")
FieldValue = Request.Form.Item(Field)
Body = Body & FieldName & ": " & FieldValue & VbCrLf
Next

Dim objCDOSYSCon

Set objCDOSYSMail = Server.CreateObject("CDO.Message")
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")

With objCDOSYSCon
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Fields.Update
End With

Set objCDOSYSMail.Configuration = objCDOSYSCon

With objCDOSYSMail

.Fields("urn:schemas:httpmail:importance").Value = 1

.From = Request.Form("email_address")

.To = "XXX@yyy.com"

.Subject = "Message from FetchIt Contact form"

.TextBody = request.form("message_body")
.Fields.Update

.Send
End With

Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing

Response.Redirect "contactthankyou.asp"
%>

Thanks

TOPICS
Server side applications

Views

533
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 06, 2009 May 06, 2009

Copy link to clipboard

Copied

LATEST

And the correct answer is ...

(Ok, so I figured it out)

<%
Dim Body
Body = request.form("a")  & vbCrlf& Request.Form("b") & vbCrlf & Request.Form("c") & vbCrlf & Request.Form("d") & vbCrlf & Request.Form("e")

Dim objCDOSYSCon

Set objCDOSYSMail = Server.CreateObject("CDO.Message")
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")

With objCDOSYSCon

.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Fields.Update
End With

Set objCDOSYSMail.Configuration = objCDOSYSCon
With objCDOSYSMail

.Fields("urn:schemas:httpmail:importance").Value = 1

.From = "form@fetchithawaii.com"
.To = "xxx@yyy.com"
.Subject = "Message from person"

.TextBody = Body
.Fields.Update

.Send
End With

Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing

%>

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines