Sending object(json) using vba - vba

Im trying to send json object in Outlook using vba. Here is my code:
Dim Msg As Outlook.MeetingItem
Set Msg = Item
Set recips = Msg.Recipients
Dim regEx As New RegExp
regEx.Pattern = "^\w+\s\w+,\sI351$"
Dim URL As String
URL = "https://webhook.site/55759d1a-7892-4c20-8d15-3b8b7f1bf3b3"
For Each recip In recips
If regEx.Test(recip.AddressEntry) And recip.AddressEntry <> "Application Management Linux1, I351" Then
Dim convertedJson As Object
Set convertedJson = JsonConverter.ParseJson("{""fields"": 123}")
Set xhr = CreateObject("MSXML2.ServerXMLHTTP.6.0")
xhr.Open "POST", URL, False
xhr.setRequestHeader "Content-Type", "application/json"
xhr.Send (convertedJson)
End If
Next
If I send just plane text it works well but i can't send convertedJson. Is it possible to send an object?
UPDATE
I can't even do Debug.Print convertedJson

I was tormented by these libraries in the end I did a very terrible thing
Dim flds, prt, id, smry, descrp, issu, name, lfbrkt, rtbrkt, cma, dbdots, jsTest, issuName As String
flds = "'fields'"
prt = "'project'"
id = "'id'"
smry = "'summary'"
descrp = "'description'"
issu = "'issuetype'"
issuName = "'Improvement'"
name = "'name'"
lfbrkt = "{"
rtbrkt = "}"
cma = ","
dbdots = ":"
jsTest = lfbrkt + flds + dbdots + " " + lfbrkt + vbCrLf + vbTab + prt + dbdots + " " + lfbrkt + vbCrLf + vbTab + vbTab + id + dbdots + " " + "30611" + vbCrLf + vbTab + rtbrkt + cma + vbCrLf + vbTab + smry + dbdots + " " + "'" + CStr(Msg.Subject) + "'" + cma + vbCrLf + vbTab + descrp + dbdots + " " + "'" + CStr(Msg.Body) + "'" + cma + vbCrLf + vbTab + issu + dbdots + " " + lfbrkt + vbCrLf + vbTab + vbTab + name + dbdots + " " + issuName + vbCrLf + vbTab + rtbrkt + vbCrLf + rtbrkt + rtbrkt
And I got this

Related

SQLCMD is not executed through asp.net application

I have asp.net application to upload database on a remote server using SQLCMD, but the command is not executed. If I execute it in cmd directly it works fine. Here is the code
Dim output
Dim result As String = ""
p.StartInfo.UseShellExecute = False
p.StartInfo.CreateNoWindow = True
p.StartInfo.RedirectStandardInput = True
p.StartInfo.RedirectStandardOutput = True
p.StartInfo.RedirectStandardError = True
p.StartInfo.Verb = "runas"
p.StartInfo.FileName = "cmd.exe"
'p.StartInfo.Arguments = "/c sqlcmd -S " + serverIP + " -U " + sa + " -P " + P#ssw0rd + " -Q" + Chr(34) + " RESTORE DATABASE " + txtDatabaseName.Text + " FROM DISK=" + Chr(39) + dbPath + Chr(39) + " with move " + Chr(39) + oldmdf + Chr(39) + " to 'C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA\" + mdf + Chr(39) + ", move " + Chr(39) + oldLog + Chr(39) + " to 'C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA\" + txtDatabaseName.Text + "_log.ldf'" + " CREATE Login " + txtDatabaseUser.Text + " WITH PASSWORD = " + Chr(39) + txtDatabasePassword.Text + Chr(39) + ";" + Chr(34)
p.StartInfo.Arguments = "/c sqlcmd -S " + ddlDatabaseServerURL.SelectedValue + " -U " + txtDatabaseServerUsername.Text + " -P " + txtDatabaseServerPassword.Text + " -Q" + Chr(34) + " RESTORE DATABASE " + txtDatabaseName.Text + " FROM DISK=" + Chr(39) + dbPath + Chr(39) + " with move " + Chr(39) + oldmdf + Chr(39) + " to 'F:\MSSQL12.MSSQLSERVER\MSSQL\DATA\" + mdf + Chr(39) + ", move " + Chr(39) + oldLog + Chr(39) + " to 'F:\MSSQL12.MSSQLSERVER\MSSQL\DATA\" + txtDatabaseName.Text + "_log.ldf'" + " CREATE Login " + txtDatabaseUser.Text + " WITH PASSWORD = " + Chr(39) + txtDatabasePassword.Text + Chr(39) + ";" + Chr(34)
Dim strFile As String = "C:\inetpub\vhost\Endpoint_Website\Endpoint_EB\mylog.txt"
Dim fileExists As Boolean = File.Exists(strFile)
Using sw As New StreamWriter(File.Open(strFile, FileMode.OpenOrCreate))
sw.WriteLine(
IIf(fileExists, p.StartInfo.Arguments, Nothing))
End Using
p.Start()
output = p.StandardOutput.ReadToEnd()

VB 2010 Conversion from string "" to type 'Double' is not valid

please help me. this is a uni project and I keep getting the error "Conversion from string "" to type 'Double' is not valid." even when I made sure that everything is in the correct type, everything with a value...etc.
I want to insert some new rows in my access database, here is a picture of the table that Im trying to insert into
enter image description here
and this is the code
the error appears at the select statement in the sub w()
Dim c As Integer
Dim b As Double
Dim a, d, z As String
a = "'" + TextBox1.Text + "'"
b = CInt(TextBox2.Text)
c = CInt(TextBox3.Text)
d = "'" + TextBox4.Text + "'"
z = "'" + ComboBox1.SelectedItem + "'"
If ComboBox1.SelectedItem = "الجبيل" Then
w("insert into employees (em_id,em_name,m_id,city,phone,salary,password)" & " values (" + 32111 + "," + a + "," + 12303 + "," + z + "," + c + "," + b + "," + d + ")")
ElseIf ComboBox1.SelectedItem = "جدة" Then
w("insert into employees (em_id,em_name,m_id,city,phone,salary,password)" & " values (" + 32111 + "," + a + "," + 12302 + "," + z + "," + c + "," + b + "," + d + ")")
ElseIf ComboBox1.SelectedItem = "الرياض" Then
w("insert into employees (em_id, em_name,m_id,city,phone,salary,password)" & " values (" + 32111 + "," + a + "," + 12301 + "," + z + "," + c + "," + b + "," + d + ")")
End If
MsgBox("تم إضافة السجل بنجاح")
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
the sub w("") is:
Public Sub w(ByVal s As String)
Dim cum As New OleDbCommand(s, con)
cum.ExecuteNonQuery()
End Sub
problem is that it works on different forms (to diffident tables and stuff), but not in here...
what should I do?

How to use Group By with AND in java codes

Trying to get values from my table but having problem with my snytaxes
there is wrong type with "Group By" usage with "AND"
any help will be apriciated
"SELECT " + C_CINSIYET + " FROM " + TABLE_COMPANYS + " WHERE "
+ C_MARKA + " = '" + companyMarka.getComp_marka() + "'"
+ " AND " + C_FIRMA + " = '"
+ companyMarka.getComp_name() + "' GROUP BY "
+ C_CINSIYET + "AND"+C_FIRMA;

Sending Email within loop in a function

code is building the email but it is only displaying one row when there is six. I got it correct on the text file but I need it to do the same in the email message. I think I got the for next statement in the wrong location. Here is the example of the code that I am having problem with. I do not know how to place the for next statement without interrupting the vbLine
For Each p In query
If p.Contract_No IsNot Nothing Then
ContractNo = p.Contract_No
Else
ContractNo = " "
End If
If p.Vendor_Name IsNot Nothing Then
VenderName = p.Vendor_Name
Else
VenderName = " "
End If
If p.Termination_Date IsNot Nothing Then
TerminationDate = p.Termination_Date
' ReportDateStr = ReportDate.ToString
TerminationDateStr = String.Format("{0:MM/dd/yyyy}", TerminationDate)
Else
TerminationDateStr = " "
End If
If p.Dept_Name IsNot Nothing Then
DeptName = p.Dept_Name
Else
DeptName = " "
End If
If p.Renewal_Option_Desc IsNot Nothing Then
RenewalOption = p.Renewal_Option_Desc
Else
RenewalOption = " "
End If
If p.Contract_Desc IsNot Nothing Then
ContractDesc = p.Contract_Desc
Else
ContractDesc = " "
End If
If p.Contact_Email IsNot Nothing Then
ContactEmail = p.Contact_Email
Else
ContactEmail = "** N/A ** "
End If
' sends email with attachment
EmailMsgBody = "-- TOTAL # OF CONTRACTS WITH FAILSAFE DATE ON " + DateStr + " IS: " + icnt.ToString + vbCrLf +
vbNewLine + " __________________ " +
vbNewLine +
vbNewLine + " *****Contracts**** " +
vbNewLine + " __________________ " +
vbNewLine +
vbNewLine + "Contract#" + " " + "Vender Name" + " " + "Termination Date" + " " + "Dept Name" + " " + "Renewal Option" + " " + "Contract Desc" + " " + "Email Address" +
vbNewLine + "------------" + " " + "-----------------" + " " + "---------------------" + " " + "--------------" + " " + "--------------------" + " " + "-----------------" + " " + "-----------------" +
vbNewLine + ContractNo.PadRight(18) + " " + _
VenderName.PadRight(38) + " " + _
TerminationDateStr.PadRight(26) + " " + _
DeptName.PadRight(27) + " " + _
RenewalOption.PadRight(45) + " " + _
ContractDesc.PadRight(32) + " " + _
ContactEmail.PadRight(11) + " "

VB.Net Iterate through two listboxes

I'm trying to iterate through two listboxes and adding all the items to one list.
Here's my code so far but I can't seem to integrate the second listbox into it.
Dim List As List(Of String) = New List(Of String)
For Each LB1 As String In Listbox1.Items
List.Add(vbTab + vbTab + "ent = maps\mp\_utility::createOneshotEffect(" + """" + LB1.ToString() + """" + ");" + vbCrLf +
vbTab + vbTab + "ent.v[ " + """" + "origin" + """" + " ] = ( " + LB2.ToString() + " );"
Next
As long as LB1 and LB2 both contain the same number of items and both are ordered the same, you could use an indexed loop (instead of a foreach loop):
Dim List As List(Of String) = New List(Of String)
For x as integer = 0 to Listbox1.Items.count - 1
List.Add(vbTab + vbTab + "ent = maps\mp\_utility::createOneshotEffect(""" + _
ListBox1.Items(x).ToString() + """);" + vbCrLf + _
vbTab + vbTab + "ent.v[ ""origin"" ] = ( " + _
ListBox2.Items(x).ToString() + " );" _
)
Next