ASP.NET SOAP Request - soap

I am successfully sending a soap request to a payment gateway as follows. But cannot obtain the response from the gateway in a meaningful manner (just string of values using the last line of code shown below). What is the best approach? Thanks.
Dim manualWebClient As New System.Net.WebClient()
manualWebClient.Headers.Add("Content-Type", "text/xml; charset=utf-8")
Dim bytArguments As Byte() = System.Text.Encoding.ASCII.GetBytes( _
"<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">" & System.Environment.NewLine & _
" <soap:Body>" & System.Environment.NewLine & _
" <CrossReferenceTransaction xmlns=""https://www.blahblah.net/"">" & System.Environment.NewLine & _
" <PaymentMessage>" & System.Environment.NewLine & _
" <MerchantAuthentication MerchantID=""blahblah"" Password=""blahblah"" />" & System.Environment.NewLine & _
" <TransactionDetails Amount=""5000"" CurrencyCode=""826"">" & System.Environment.NewLine & _
" <MessageDetails TransactionType=""COLLECTION"" NewTransaction=""TRUE"" CrossReference=""140519132324310202778936"" />" & System.Environment.NewLine & _
" <OrderID>order12345</OrderID>" & System.Environment.NewLine & _
" <OrderDescription>Monthly Subscription</OrderDescription>" & System.Environment.NewLine & _
" <TransactionControl>" & System.Environment.NewLine & _
" <EchoCardType>TRUE</EchoCardType>" & System.Environment.NewLine & _
" <EchoAVSCheckResult>TRUE</EchoAVSCheckResult>" & System.Environment.NewLine & _
" <EchoCV2CheckResult>TRUE</EchoCV2CheckResult>" & System.Environment.NewLine & _
" <EchoAmountReceived>TRUE</EchoAmountReceived>" & System.Environment.NewLine & _
" <DuplicateDelay>60</DuplicateDelay>" & System.Environment.NewLine & _
" </TransactionControl>" & System.Environment.NewLine & _
" </TransactionDetails>" & System.Environment.NewLine & _
" </PaymentMessage>" & System.Environment.NewLine & _
" </CrossReferenceTransaction>" & System.Environment.NewLine & _
" </soap:Body>" & System.Environment.NewLine & _
"</soap:Envelope>")
Dim bytRetData As Byte() = manualWebClient.UploadData("https://blahblahblah.com:4430", "POST", bytArguments)
Response.Write(System.Text.Encoding.ASCII.GetString(bytRetData))

Related

VBS Script that shows the files created on a specific date

I want to create a script that shows the files created on a specific date in a specific location.
As for now I created this:
Set objWMIService = GetObject("winmgmts:" & "!\\" & "." & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery ("Select * from CIM_DataFile where Drive='C:' AND Path='\\' AND CreationDate Like '20071107%' ")
For Each objFile in colFiles
Buffer = Buffer & objFile.FileName & " - " & objFile.CreationDate & vbNewLine
Next
Wscript.echo Buffer
But I am getting error in this line: " AND CreationDate Like '20071107%' "
So it does not work in such a way as I thought it will be - in C:\ I have a lot eula.txt files created on 2007 11 07.
I do not ask about finished code, but only for a clue. Thanks!
WHERE clause of a WQL query defends or inhibits from using wildcards in CIM_DATETIME values. Use SWbemDateTime object as follows:
option explicit
On Error GoTo 0
Dim strResult: strResult = Wscript.ScriptName
Dim objWMIService, colFiles, objFile, dTargetDate, dMinDate, dMaxDate, dateTime
Set dateTime = CreateObject("WbemScripting.SWbemDateTime")
dTargetDate = #2007-11-07# ' date literal in yyyy-mm-dd format
dateTime.SetVarDate( dTargetDate) ' convert to CIM_DATETIME
dMinDate = datetime
dateTime.SetVarDate( DateAdd( "d", 1, dTargetDate))
dMaxDate = datetime
strResult = strResult & vbNewLine & dMaxDate
Set objWMIService = GetObject("winmgmts:" & "!\\" & "." & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery ( _
"Select * from CIM_DataFile where Drive='c:' AND Path='\\'" _
& " AND CreationDate >= '" & dMinDate & "'" _
& " AND CreationDate < '" & dMaxDate & "'" _
)
If colFiles.Count = 0 Then
strResult = strResult & vbNewLine & "no files found"
Else
For Each objFile in colFiles
strResult = strResult & vbNewLine & objFile.FileName & " " & objFile.Extension _
& " - " & objFile.CreationDate
Next
End If
Wscript.Echo strResult
Wscript.Quit

Stop search dialog from coming up in MS Access form

The "Find and Replace" dialog keeps coming up after my button event runs. Why and what can I do to stop it?
Private Sub btn_Find_Click()
Dim query_string As String
'MsgBox (Me.InventoryDetailsID)
query_string = "SELECT " & _
"tbl_Inventory_Header.InventoryHeaderID, " & _
"tbl_Inventory_Header.InventoryTitle, " & _
"tbl_Inventory_Header.Author, " & _
"tbl_Lookup_MediaTypes.MediaTypeDescription, " & _
"tbl_Inventory_Details.ShelfNumber, " & _
"tbl_Lookup_Vendors.VendorName, " & _
"tbl_Inventory_Header.Year_Publish_Produced, " & _
"tbl_Inventory_Header.InventoryDescription " & _
"FROM (((tbl_Inventory_Header " & _
"INNER JOIN tbl_Inventory_Details ON tbl_Inventory_Details.InventoryHeaderID = tbl_Inventory_Header.InventoryHeaderID) " & _
"INNER JOIN tbl_Lookup_Vendors ON tbl_Lookup_Vendors.VendorID = tbl_Inventory_Header.VendorID) " & _
"INNER JOIN tbl_Lookup_MediaTypes ON tbl_Lookup_MediaTypes.MediaTypeID = tbl_Inventory_Header.MediaTypeID) " & _
"WHERE tbl_Inventory_Details.InventoryDetailsID LIKE '" & Me.InventoryDetailsID & "';"
Me.Controls!test.Value = query_string
'MsgBox ("Querying for record data")
CurrentDb.QueryDefs("qry_Inventory_Header_ISBN").SQL = query_string
Dim recordSet As DAO.recordSet
Set recordSet = CurrentDb.OpenRecordset("qry_Inventory_Header_ISBN")
If Not recordSet.RecordCount > 0 Then
MsgBox ("No record found for barcode " & Me.Controls!InventoryDetailsID)
GoTo Exit_btn_SearchByHeaderId_Click
Else
'MsgBox ("record found")
End If
'MsgBox (recordSet!InventoryTitle)
'MsgBox ("filling controls")
Me.Controls!InventoryTitle.Value = recordSet!InventoryTitle
Me.Controls!Author = recordSet!Author
Me.Controls!MediaTypeDescription = recordSet!MediaTypeDescription
Me.Controls!VendorName = recordSet!VendorName
Me.Controls!Year_Publish_Produced = recordSet!Year_Publish_Produced
Me.Controls!InventoryDescription = recordSet!InventoryDescription
Me.Controls!ShelfNumber = recordSet!ShelfNumber
Me.Controls!ISBN.SetFocus
On Error GoTo Err_btn_SearchByHeaderId_Click
'MsgBox ("got error")
Screen.PreviousControl.SetFocus
DoCmd.RunCommand acCmdFind
Exit_btn_SearchByHeaderId_Click:
'MsgBox ("exit")
Exit Sub
Err_btn_SearchByHeaderId_Click:
MsgBox Err.Description
Resume Exit_btn_SearchByHeaderId_Click
End Sub
The Find dialog derives at this command DoCmd.RunCommand acCmdFind towards the bottom just before the error handlers.
And according to the code, this Find command will always run since no If Then, Do While Loop, For Next, or Goto is wrapped around it.
Consider removing it, re-positioning it, or placing an Exit Sub before it if this Find command should be part of an error handle.

Form Search to find all records with value in subform (regardless of field value in)

After searching the forum, I haven't found any questions/answers quite like mine.
I have a main form with four different search fields - last name, city, phone number, and ID. I want to have a search of any of these fields (or combination of these fields) to find all records in the subform with a matching value - regardless of which field that value is in (i.e. there are multiple address fields in the subform, so the city could appear in any of these).
Additionally, if a Last Name AND City are entered I only want to return records in the subform that include both values.
Thank you in advance!
I don't think this can be done without employing VBA. You would need to add code to the AfterUpdate event for each search field's control on the main form that would subsequently update the subform's filter. I'm not sure how complex filters are allowed to be, though, which could be a problem because it's going to be a monster of a filter.
Here's an untested example that uses placeholders for the potential number of different fields in the subform (as you indicated there could be multiples of any of them) and assuming your phone number and ID are numbers and that your search controls have data validation in place to ensure that:
Private Sub last_name_AfterUpdate()
Call FilterSubForm()
End Sub
Private Sub city_AfterUpdate()
Call FilterSubForm()
End Sub
Private Sub phone_number_AfterUpdate()
Call FilterSubForm()
End Sub
Private Sub ID_AfterUpdate()
Call FilterSubForm()
End Sub
Private Sub FilterSubForm()
Dim sLastName As String
Dim sCity As String
Dim sPhone As String
Dim sID As String
Dim sFilter As String
sLastName = Trim(Me.[last name])
sCity = Trim(Me.city)
sPhone = Trim(Me.[phone number])
sID = Trim(Me.ID)
If sLastName != "" And sCity != "" Then
sFilter = "(([last_name_1] = '" & sLastName & "' " _
& "OR [last_name_2] = '" & sLastName & "' " _
& "OR [last_name_etc] = '" & sLastName & "') " _
& "AND " _
& "([city_1] = '" & sCity & "' " _
& "OR [city_2] = '" & sCity & "' " _
& "OR [city_etc] = '" & sCity & "'))"
If sPhone != "" Then
sFilter = sFilter _
& " AND " _
& "[phone_number_1] = " & sPhone & " " _
& "OR [phone_number_2] = " & sPhone & " " _
& "OR [phone_number_etc] = " & sPhone
End If
If sID != "" Then
sFilter = sFilter _
& IIf(sPhone != "", " OR ", " AND ") _
& "[ID_1] = " & sID & " " _
& "OR [ID_2] = " & sID & " " _
& "OR [ID_etc] = " & sID
End If
Else
If sLastName != "" Then
sFilter = "[last_name_1] = '" & sLastName & "' " _
& "OR [last_name_2] = '" & sLastName & "' " _
& "OR [last_name_etc] = '" & sLastName & "'"
End If
If sCity != "" Then
sFilter = sFilter _
& IIf(sLastName != "", " OR ", "") _
& "[city_1] = '" & sCity & "' " _
& "OR [city_2] = '" & sCity & "' " _
& "OR [city_etc] = '" & sCity & "'"
End If
If sPhone != "" Then
sFilter = sFilter _
& IIf(sCity != "", " OR ", "") _
& "[phone_number_1] = " & sPhone & " " _
& "OR [phone_number_2] = " & sPhone & " " _
& "OR [phone_number_etc] = " & sPhone
End If
If sID != "" Then
sFilter = sFilter _
& IIf(sPhone != "", " OR ", "") _
& "[ID_1] = " & sID & " " _
& "OR [ID_2] = " & sID & " " _
& "OR [ID_etc] = " & sID
End If
End If
Me.[your_subform].Filter = sFilter
Me.[your_subform].FilterOn = True
Me.[your_subform].Requery
End Sub

ASP vbscript email form - only send fields with value

This is the ASP code to send email..
<%
'declare variables
Dim EmailFrom
Dim EmailTo
Dim Subject
Dim DealerName
Dim DealerNumber
Dim InvoiceNumber
Dim PONumber
Dim InvoiceDate
Dim ModelNumber
Dim SerialNumber
Dim ConditionofUnit
Dim ReasonforRMA
Dim OtherText
Dim ModelNumber2
Dim SerialNumber2
Dim ConditionofUnit2
Dim ReasonforRMA2
Dim OtherText2
Dim ModelNumber3
Dim SerialNumber3
Dim ConditionofUnit3
Dim ReasonforRMA3
Dim OtherText3
Dim ModelNumber4
Dim SerialNumber4
Dim ConditionofUnit4
Dim ReasonforRMA4
Dim OtherText4
Dim ModelNumber5
Dim SerialNumber5
Dim ConditionofUnit5
Dim ReasonforRMA5
Dim OtherText5
Dim ModelNumber6
Dim SerialNumber6
Dim ConditionofUnit6
Dim ReasonforRMA6
Dim OtherText6
Dim ModelNumber7
Dim SerialNumber7
Dim ConditionofUnit7
Dim ReasonforRMA7
Dim OtherText7
Dim ModelNumber8
Dim SerialNumber8
Dim ConditionofUnit8
Dim ReasonforRMA8
Dim OtherText8
Dim ModelNumber9
Dim SerialNumber9
Dim ConditionofUnit9
Dim ReasonforRMA9
Dim OtherText9
Dim ModelNumber10
Dim SerialNumber10
Dim ConditionofUnit10
Dim ReasonforRMA10
Dim OtherText10
' get posted data into variables
EmailFrom = Trim(Request.Form("EmailFrom"))
EmailTo = "ouremail#domain.com"
Subject = "my subject"
DealerName = Trim(Request.Form("DealerName"))
DealerNumber = Trim(Request.Form("DealerNumber"))
InvoiceNumber = Trim(Request.Form("InvoiceNumber"))
PONumber = Trim(Request.Form("PONumber"))
InvoiceDate = Trim(Request.Form("InvoiceDate"))
ModelNumber = Trim(Request.Form("ModelNumber"))
SerialNumber = Trim(Request.Form("SerialNumber"))
ConditionofUnit = Trim(Request.Form("ConditionofUnit"))
ReasonforRMA = Trim(Request.Form("ReasonforRMA"))
OtherText = Trim(Request.Form("OtherText"))
ModelNumber2 = Trim(Request.Form("ModelNumber2"))
SerialNumber2 = Trim(Request.Form("SerialNumber2"))
ConditionofUnit2 = Trim(Request.Form("ConditionofUnit2"))
ReasonforRMA2 = Trim(Request.Form("ReasonforRMA2"))
OtherText2 = Trim(Request.Form("OtherText2"))
ModelNumber3 = Trim(Request.Form("ModelNumber3"))
SerialNumber3 = Trim(Request.Form("SerialNumber3"))
ConditionofUnit3 = Trim(Request.Form("ConditionofUnit3"))
ReasonforRMA3 = Trim(Request.Form("ReasonforRMA3"))
OtherText3 = Trim(Request.Form("OtherText3"))
ModelNumber4 = Trim(Request.Form("ModelNumber4"))
SerialNumber4 = Trim(Request.Form("SerialNumber4"))
ConditionofUnit4 = Trim(Request.Form("ConditionofUnit4"))
ReasonforRMA4 = Trim(Request.Form("ReasonforRMA4"))
OtherText4 = Trim(Request.Form("OtherText4"))
ModelNumber5 = Trim(Request.Form("ModelNumber5"))
SerialNumber5 = Trim(Request.Form("SerialNumber5"))
ConditionofUnit5 = Trim(Request.Form("ConditionofUnit5"))
ReasonforRMA5 = Trim(Request.Form("ReasonforRMA5"))
OtherText5 = Trim(Request.Form("OtherText5"))
ModelNumber6 = Trim(Request.Form("ModelNumber6"))
SerialNumber6 = Trim(Request.Form("SerialNumber6"))
ConditionofUnit6 = Trim(Request.Form("ConditionofUnit6"))
ReasonforRMA6 = Trim(Request.Form("ReasonforRMA6"))
OtherText6 = Trim(Request.Form("OtherText6"))
ModelNumber7 = Trim(Request.Form("ModelNumber7"))
SerialNumber7 = Trim(Request.Form("SerialNumber7"))
ConditionofUnit7 = Trim(Request.Form("ConditionofUnit7"))
ReasonforRMA7 = Trim(Request.Form("ReasonforRMA7"))
OtherText7 = Trim(Request.Form("OtherText7"))
ModelNumber8 = Trim(Request.Form("ModelNumber8"))
SerialNumber8 = Trim(Request.Form("SerialNumber8"))
ConditionofUnit8 = Trim(Request.Form("ConditionofUnit8"))
ReasonforRMA8 = Trim(Request.Form("ReasonforRMA8"))
OtherText8 = Trim(Request.Form("OtherText8"))
ModelNumber9 = Trim(Request.Form("ModelNumber9"))
SerialNumber9 = Trim(Request.Form("SerialNumber9"))
ConditionofUnit9 = Trim(Request.Form("ConditionofUnit9"))
ReasonforRMA9 = Trim(Request.Form("ReasonforRMA9"))
OtherText9 = Trim(Request.Form("OtherText9"))
ModelNumber10 = Trim(Request.Form("ModelNumber10"))
SerialNumber10 = Trim(Request.Form("SerialNumber10"))
ConditionofUnit10 = Trim(Request.Form("ConditionofUnit10"))
ReasonforRMA10 = Trim(Request.Form("ReasonforRMA10"))
OtherText10 = Trim(Request.Form("OtherText10"))
Dim mail
Set mail = Server.CreateObject("CDONTS.NewMail")
mail.To = EmailTo
mail.BodyFormat = 0
mail.MailFormat = 0
mail.From = EmailFrom
mail.Subject = Subject
mail.Body = "This is an email generated." & "<br>" & "<br>" & _
"<b>Dealer Name: </b>" & DealerName & "<br>" & _
"<b>Dealer Number: </b>" & DealerNumber & "<br>" & _
"<b>Invoice Number: </b>" & InvoiceNumber & "<br>" & _
"<b>PO Number: </b>" & PONumber & "<br>" & _
"<b>Invoice Date: </b>" & InvoiceDate & "<br>" & _
"<b>------ ITEM 1 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText & "<br>" & _
"<b>------ ITEM 2 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber2 & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber2 & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit2 & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA2 & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText2 & "<br>" & _
"<b>------ ITEM 3 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber3 & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber3 & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit3 & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA3 & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText3 & "<br>" & _
"<b>------ ITEM 4 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber4 & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber4 & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit4 & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA4 & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText4 & "<br>" & _
"<b>------ ITEM 5 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber5 & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber5 & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit5 & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA5 & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText5 & "<br>" & _
"<b>------ ITEM 6 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber6 & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber6 & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit6 & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA6 & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText6 & "<br>" & _
"<b>------ ITEM 7 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber7 & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber7 & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit7 & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA7 & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText7 & "<br>" & _
"<b>------ ITEM 8 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber8 & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber8 & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit8 & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA8 & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText8 & "<br>" & _
"<b>------ ITEM 9 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber9 & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber9 & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit9 & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA9 & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText9 & "<br>" & _
"<b>------ ITEM 10 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber10 & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber10 & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit10 & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA10 & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText10 & "<br>"
mail.Send
' redirect to success page
Response.Redirect("complete.html")
%>
So as you can see instead of sending all 10 items in every email, does anyone know how I can only send the items that actually get filled out with values? Only filling out 1 item is required with the ability to do up to 10..
EDIT: I changed it to this:
Dim mail
Set mail = Server.CreateObject("CDONTS.NewMail")
mail.To = EmailTo
mail.BodyFormat = 0
mail.MailFormat = 0
mail.From = EmailFrom
mail.Subject = Subject
If Request.Form("ModelNumber2") <> "" Then
mail.Body = "This is an email generated." & "<br>" & "<br>" & _
"<b>Dealer Name: </b>" & DealerName & "<br>" & _
"<b>Dealer Number: </b>" & DealerNumber & "<br>" & _
"<b>Invoice Number: </b>" & InvoiceNumber & "<br>" & _
"<b>PO Number: </b>" & PONumber & "<br>" & _
"<b>Invoice Date: </b>" & InvoiceDate & "<br>" & _
"<b>------ ITEM 1 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText & "<br>" & _
"<b>------ ITEM 2 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber2 & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber2 & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit2 & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA2 & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText2 & "<br>"
ElseIf Request.Form("ModelNumber2") <> "" And Request.Form("ModelNumber3") <> "" Then
mail.Body = "This is an email generated." & "<br>" & "<br>" & _
"<b>Dealer Name: </b>" & DealerName & "<br>" & _
"<b>Dealer Number: </b>" & DealerNumber & "<br>" & _
"<b>Invoice Number: </b>" & InvoiceNumber & "<br>" & _
"<b>PO Number: </b>" & PONumber & "<br>" & _
"<b>Invoice Date: </b>" & InvoiceDate & "<br>" & _
"<b>------ ITEM 1 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText & "<br>" & _
"<b>------ ITEM 2 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber2 & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber2 & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit2 & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA2 & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText2 & "<br>" & _
"<b>------ ITEM 3 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber3 & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber3 & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit3 & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA3 & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText3 & "<br>"
'ElseIf Request.Form("ModelNumber4") = "" Then
'ElseIf Request.Form("ModelNumber5") = "" Then
'ElseIf Request.Form("ModelNumber6") = "" Then
'ElseIf Request.Form("ModelNumber7") = "" Then
'ElseIf Request.Form("ModelNumber8") = "" Then
'ElseIf Request.Form("ModelNumber9") = "" Then
'ElseIf Request.Form("ModelNumber10") = "" Then
Else
mail.Body = "This is an email generated." & "<br>" & "<br>" & _
"<b>Dealer Name: </b>" & DealerName & "<br>" & _
"<b>Dealer Number: </b>" & DealerNumber & "<br>" & _
"<b>Invoice Number: </b>" & InvoiceNumber & "<br>" & _
"<b>PO Number: </b>" & PONumber & "<br>" & _
"<b>Invoice Date: </b>" & InvoiceDate & "<br>" & _
"<b>------ ITEM 1 ------</b><br>" & _
"<b>Model Number: </b>" & ModelNumber & "<br>" & _
"<b>Serial Number: </b>" & SerialNumber & "<br>" & _
"<b>Condition of Unit </b>" & ConditionofUnit & "<br>" & _
"<b>Reason for RMA: </b>" & ReasonforRMA & "<br>" & _
"<b>Other Text <i>(If Applicable)</i></b>: " & OtherText & "<br>"
End If
mail.Send
But when I fill out 3 items it still only sends the email for 2 items. What am I missing here?
I would reduce the amount of typing with a loop...
(easiest if you add the "1" to the end of the first set of fields)
Been a while since I did any Classic ASP but from memory this should work:
mail.Body = "This is an email generated." & "<br>" & "<br>" & _
"<b>Dealer Name: </b>" & DealerName & "<br>" & _
"<b>Dealer Number: </b>" & DealerNumber & "<br>" & _
"<b>Invoice Number: </b>" & InvoiceNumber & "<br>" & _
"<b>PO Number: </b>" & PONumber & "<br>" & _
"<b>Invoice Date: </b>" & InvoiceDate & "<br>"
for i = 1 to 10
if trim(Request.Form("ModelNumber" & cstr(i))) <> "" then
mail.Body += "<b>------ ITEM " & cstr(i) & " ------</b><br>" & _
"<b>Model Number: </b>" & trim(Request.Form("ModelNumber" & cstr(i)) & "<br>" & _
"<b>Serial Number: </b>" & trim(Request.form("SerialNumber" & cstr(i)) & "<br>" & _
...
end if
next

How to reconcile the lack of Macros in Visual Studio 2012

My organization has extremely restrictive and rigid rules our code must comply with in order to obtain certification and accreditation. For the last decade or so we have developed nearly a hundred VS macros that format code, generate comments blocks, enforce style rules, etc.
Our macros are not the kind you record some mouse movements; they all depend on the EnvDTE* VS automation objects. With VS 2012 dropping macros we are at a loss as to whether or not we will even be able to upgrade, without imposing a drastic impact on the team.
I am aware that the direction Microsoft is going is the VS Addins route and I am willing to investigate that route but I am having trouble finding code samples or documentation on how a VS Add-In can interact with the active code file in Visual Studio.
For example, here is a macro we use all the time that applies our Try wrapper design pattern to all methods that are capable of throwing unhandled exceptions
''' <summary>
''' Wraps active method in Try* access wrappers.
''' </summary>
Sub InsertSingleMethodTryWrappers()
Dim textSelection As TextSelection
Dim codeElement As CodeElement
textSelection = DTE.ActiveWindow.Selection
DTE.UndoContext.Open("Generate Try Wrappers") 'Allow for single Undo operation to rollback all changes
Try
codeElement = textSelection.ActivePoint.CodeElement(vsCMElement.vsCMElementFunction)
If Not (codeElement Is Nothing) Then
Dim textSelection2 As TextSelection
Dim codeFunction As CodeFunction
'Dim codeFunction2 As CodeFunction2
Dim editPoint As EditPoint
Dim codeParameter As CodeParameter
Dim parameters As CodeElements
Dim codeElement2 As CodeElement
Dim isVirtual As Boolean = False
Dim strVirtual As String = String.Empty
Dim strTypeName As String = String.Empty
'' Cast the codeElement to codeFunction object
codeFunction = codeElement
'' Move cursor to the start of the method
textSelection.MoveToPoint(codeFunction.GetStartPoint(vsCMPart.vsCMPartHeader))
'' Should be able to use codeFunction.Kind.ToString to retrieve the function type
'' vsCMFunctionVirtual if the method is virtual but there is a bug in the API
'' that returns vsCMFunctionFunction even if the function is virtual (C# parsing bug?)
''
'' vsCMFunction Type
'' http://msdn.microsoft.com/en-us/library/envdte.vscmfunction(v=vs.80).aspx
''
'' This frustrating bug means that we have to parse the header to determine if virtual
textSelection.EndOfLine(True)
If (textSelection.Text.IndexOf("virtual") > 0) Then
isVirtual = True
strVirtual = " virtual"
End If
textSelection.StartOfLine()
'' Try not to screw up comments and attributes
editPoint = GetNoneCommentOrAttribHeaderEditPoint(textSelection)
If editPoint Is Nothing Then
MsgBox("Could not find a line above the method that isn't a comment or attribute", _
MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Error")
Exit Sub
End If
'' Create an EditPoint to inject Try* methods
'editPoint = textSelection.TopPoint.CreateEditPoint()
'editPoint.LineUp() 'Move up 1 line
editPoint.EndOfLine() 'Go to end of line above signature
editPoint.Insert(Environment.NewLine) 'Insert blank line for cleanliness
editPoint.Insert(Environment.NewLine) 'Insert blank line for cleanliness
editPoint.LineUp() 'Move up 1 line
parameters = codeFunction.Parameters
Dim strAccess As String : strAccess = GetAccessModifierString(codeFunction.Access) 'Access Modifier
Dim strName As String : strName = codeElement.Name 'Member Name
Dim strType As String : strType = codeFunction.Type.AsString 'Type Name
'' Get the un-qualified object name
If (strType.IndexOf(".") > 0) Then
Dim arrType() As String = strType.Split(".")
strTypeName = arrType(arrType.Length - 1)
Else
strTypeName = strType
End If
''' Create parameter type/name arrayList
Dim arrParams As System.Collections.ArrayList
arrParams = New System.Collections.ArrayList()
For Each codeElement2 In parameters
codeParameter = codeElement2
arrParams.Add(codeParameter.Type.AsString.Trim & " " & codeParameter.Name.Trim & ", ")
Next
Dim strParams As String
Dim strParamNames As String
'' Capture a string with parameter names and types and one just of names
For Each strParam As String In arrParams
strParams += strParam
strParamNames += strParam.Split(" ")(1)
Next
'' Trim excess comma for members of type void
If strType = "void" Then
If Not String.IsNullOrEmpty(strParams) Then
If strParams.TrimEnd.EndsWith(",") Then
strParams = strParams.TrimEnd()
strParams = strParams.Remove(strParams.Length - 1, 1)
End If
End If
End If
'' -- Try* swallow methods --
'' we don't care what the exception is, we just want to know success or failure
Dim strTrySwallowSignature As String
Dim strTrySwallowBody As String
Dim strTryOutParams As String
Dim strOutDef As String
Dim strOutSig As String
'' Members of type 'void' get no out parameters
If Not strType = "void" Then
strTryOutParams = "out " & strTypeName & " outObjType"
strOutDef = "outObjType = null;"
strOutSig = " out outObjType,"
End If
strTrySwallowSignature = vbTab & vbTab & strAccess & strVirtual & " bool Try" & strName & "(" & strParams & strTryOutParams & ")"
strTrySwallowBody = vbCrLf & vbTab & vbTab & "{" _
& vbCrLf & vbTab & vbTab & vbTab & "Exception exception;" _
& vbCrLf & vbTab & vbTab & vbTab & strOutDef _
& vbCrLf & vbTab & vbTab & vbTab & "return Try" & strName & "(" & strParamNames & strOutSig & " out exception);" _
& vbCrLf & vbTab & vbTab & "}"
'' -- Try* re-throw methods --
'' We want to know success or failure as well as the exception if it failed
Dim strTryReThrowSignature As String
Dim strTryReThrowBody As String
'' Members of type 'void' only get out exception parameter
If Not strType = "void" Then
strTryOutParams = "out " & strTypeName & " outObjType, out Exception exception"
'strOutDef = "outObjType = new " & strTypeName & "();"
strOutDef = "outObjType = null;"
Else
strTryOutParams = "out Exception exception"
End If
strTryReThrowSignature = vbTab & vbTab & strAccess & strVirtual & " bool Try" & strName & "(" & strParams & strTryOutParams & ")"
strTryReThrowBody = vbCrLf & vbTab & vbTab & "{" _
& vbCrLf & vbTab & vbTab & vbTab & "bool result = false;" _
& vbCrLf & vbTab & vbTab & vbTab & "exception = null;" _
& vbCrLf & vbTab & vbTab & vbTab & strOutDef _
& vbCrLf & vbTab & vbTab & vbTab & "try" _
& vbCrLf & vbTab & vbTab & vbTab & "{" _
& vbCrLf & vbTab & vbTab & vbTab & vbTab & "// insert code here " _
& vbCrLf & vbTab & vbTab & vbTab & vbTab & "//result = true; " _
& vbCrLf & vbTab & vbTab & vbTab & vbTab & "throw new NotImplementedException();" _
& vbCrLf & vbTab & vbTab & vbTab & "}" _
& vbCrLf & vbTab & vbTab & vbTab & "catch (Exception e)" _
& vbCrLf & vbTab & vbTab & vbTab & "{" _
& vbCrLf & vbTab & vbTab & vbTab & vbTab & "exception = e;" _
& vbCrLf & vbTab & vbTab & vbTab & "}" _
& vbCrLf & vbTab & vbTab & vbTab & "return result;" _
& vbCrLf & vbTab & vbTab & "}"
editPoint.Insert(strTrySwallowSignature)
editPoint.Insert(strTrySwallowBody)
editPoint.Insert(vbCrLf & vbCrLf)
editPoint.Insert(strTryReThrowSignature)
editPoint.Insert(strTryReThrowBody)
editPoint.Insert(vbCrLf)
End If
Catch Ex As Exception
MsgBox(Ex.Message)
Finally
DTE.UndoContext.Close()
End Try
End Sub
Can someone direct me to how a VS 2012 Add-in can manipulate the active/open code file (using EnvDTE* or whatever object model is available for 2012)?
Well that turned out to be really simple. Turns out the Macro object model is part of the VS model so no problem.
http://msdn.microsoft.com/en-us/library/za2b25t3%28v=vs.110%29.aspx
http://msdn.microsoft.com/en-us/library/ms228776.aspx
I should have know Microsoft wouldn't have left us Macro-dependant developers out in the cold like that!