【解決方法】承認フォームは、承認のためにマネージャーに電子メールで送信されます


プロジェクトは、基本的にユーザーがフォームに入力し、送信ボタンをクリックすると、承認のためにマネージャーに送信されるフォームです。 マネージャーは、フォームを承認するためのリンクを電子メールで受け取ります。 マネージャーは、承認ボタンと拒否ボタンがあることを除いて、ユーザーが記入したのと同じフォームに移動する必要があります。 どちらを選択しても、フォームが承認されたか却下されたかを知らせる別の電子メールがユーザーに送信されます。

C#
If Request.Form("btnSubmit") <> "" Then
  Dim UserName
  Dim UserMessage
  UserName = Request.Form("txtName")
  UserMessage = Request.Form("txtMessage")
  Dim Message
  Message = "Mail from the Web site" & vbCrlf & vbCrLf
  Message = Message & "User " & UserName & _
       " left the following message: " & vbCrLf
  Message = Message & UserMessage & vbCrLf & vbCrLf
  Const cdoSendUsingPort = 2

  Dim oConfiguration
  Dim oMessage
  Dim oFields
  Set oConfiguration = CreateObject("CDO.Configuration")

  Set oFields = oConfiguration.Fields
  ' 25 on the SMTP server.
  With oFields
  .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") _
      = cdoSendUsingPort
  .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
      = "SMTP.YourProvider.Com" 
  .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") _
      = 10 
  .Update
  End With

  ' Apply the settings to the message.
  With oMessage
    Set .Configuration = oConfiguration
    .To = "You@YourProvider.Com"
    .Bcc = "SomeoneElse@YourProvider.Com"
    .From = "YourWebsite@YourProvider.Com"
    .Subject = "User " & UserName & " left a message"
    .HTMLBody = Message
    .Send
  End With

  ' Clean up variables.
  Set oMessage = Nothing
  Set oConfiguration = Nothing
  Set oFields = Nothing

  Response.Redirect("ThankYou")
End If 

誰か助けてください。 コードはエラーを表示します。 。

解決策 1

If Request.Form("btnSubmit") <> "" Then
  Dim UserName
  Dim UserMessage
  UserName = Request.Form("txtName")
  UserMessage = Request.Form("txtMessage")
  Dim Message
  Message = "Mail from the Web site" & vbCrlf & vbCrLf
  Message = Message & "User " & UserName & _
       " left the following message: " & vbCrLf
  Message = Message & UserMessage & vbCrLf & vbCrLf
  Const cdoSendUsingPort = 2

  Dim oConfiguration
  Dim oMessage
  Dim oFields
  Set oConfiguration = CreateObject("CDO.Configuration")

  Set oFields = oConfiguration.Fields
  ' 25 on the SMTP server.
  With oFields
  .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") _
      = cdoSendUsingPort
  .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
      = "SMTP.YourProvider.Com" 
  .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") _
      = 10 
  .Update
  End With

  ' Apply the settings to the message.
  With oMessage
    Set .Configuration = oConfiguration
    .To = "You@YourProvider.Com"
    .Bcc = "SomeoneElse@YourProvider.Com"
    .From = "YourWebsite@YourProvider.Com"
    .Subject = "User " & UserName & " left a message"
    .HTMLBody = Message
    .Send
  End With

  ' Clean up variables.
  Set oMessage = Nothing
  Set oConfiguration = Nothing
  Set oFields = Nothing

  Response.Redirect("ThankYou")
End If

コメント

タイトルとURLをコピーしました