Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(VB.NET) MedTunnel: Send Message Text OnlySee more MedTunnel ExamplesDemonstrates the MedTunnel SendMessage method to send a message to one or more recipients. For more information, see https://server.medtunnel.com/apidocs/html/M_MedTunnelMsg_Controllers_MessageController_SendMessage.htm
' This example assumes the Chilkat API to have been previously unlocked. ' See Global Unlock Sample for sample code. Dim http As New Chilkat.Http Dim success As Boolean ' Implements the following CURL command: ' curl https://server.medtunnel.com/MedTunnelMsg/api/Message/SendMessage -X POST -k ' -F "ApplicationId=yourApplicationId" -F "LocationId=yourLocationId" ' -F "MedTunnelId=yourMedTunnelId" -F "MedTunnelPassword=yourMedTunnelPassword" ' -F "To=recipientsMedTunnelId" ' -F "Body=Test of SendMessage" ' Use the following online tool to generate HTTP code from a CURL command ' Convert a cURL Command to HTTP Source Code Dim req As New Chilkat.HttpRequest req.HttpVerb = "POST" req.Path = "/MedTunnelMsg/api/Message/SendMessage" req.ContentType = "multipart/form-data" req.AddParam("ApplicationId","yourApplicationId") req.AddParam("LocationId","yourLocationId") req.AddParam("MedTunnelId","yourMedTunnelId") req.AddParam("MedTunnelPassword","yourMedTunnelPassword") req.AddParam("To","recipientsMedTunnelId") req.AddParam("Body","Test") Dim resp As Chilkat.HttpResponse = http.SynchronousRequest("server.medtunnel.com",443,True,req) If (http.LastMethodSuccess = False) Then Debug.WriteLine(http.LastErrorText) Exit Sub End If Dim sbResponseBody As New Chilkat.StringBuilder resp.GetBodySb(sbResponseBody) Dim jResp As New Chilkat.JsonObject jResp.LoadSb(sbResponseBody) jResp.EmitCompact = False Debug.WriteLine("Response Body:") Debug.WriteLine(jResp.Emit()) Dim respStatusCode As Integer = resp.StatusCode Debug.WriteLine("Response Status Code = " & respStatusCode) If (respStatusCode >= 400) Then Debug.WriteLine("Response Header:") Debug.WriteLine(resp.Header) Debug.WriteLine("Failed.") Exit Sub End If ' Sample JSON response: ' (Sample code for parsing the JSON response is shown below) ' { ' "ReturnCode": 1, ' "ReturnCodeText": "Success", ' "Data": "{\"Id\":989432,\"FromUserId\":36990,\"FromMailBoxId\":36965, ... \"SendGlobalNotifications\":false}" ' } ' Sample code for parsing the JSON response... ' Use the following online tool to generate parsing code from sample JSON: ' Generate Parsing Code from JSON Dim ReturnCode As Integer = jResp.IntOf("ReturnCode") Dim ReturnCodeText As String = jResp.StringOf("ReturnCodeText") Dim Data As String = jResp.StringOf("Data") ' Load the Data into another JSON object and parse.. Dim jsonData As New Chilkat.JsonObject jsonData.Load(Data) jsonData.EmitCompact = False Debug.WriteLine(jsonData.Emit()) ' { ' "Id": 989436, ' "FromUserId": 36990, ' "FromMailBoxId": 36965, ' "FromUserType": 0, ' "FromUserName": "...", ' "FromUserFullName": "...", ' "FromUserAccountName": "...", ' "FromUserAccountTitle": "...", ' "ToUserId": 36990, ' "ToUserType": 1, ' "ToUserMailboxId": "36965", ' "ToUserName": "...", ' "ToUserFullName": "...", ' "EmailAddress": "", ' "Password": "", ' "Subject": "", ' "PatientMedTunnelId": "", ' "Body": "Test", ' "DateReceived": "4/29/2021 2:29:18 PM", ' "DisplayDateReceived": "04/29/2021 2:29 PM", ' "ViewCount": 0, ' "ViewedOn": "", ' "AttachmentCount": 0, ' "AttachmentNames": [ ' ], ' "AllRecipients": [ ' { ' "Id": 989436, ' "UserName": "...", ' "AccountId": 0, ' "AccountName": "...", ' "AccountTitle": "", ' "FirstName": "...", ' "LastName": "...", ' "EmailAddress": "", ' "LastSentOn": "", ' "SendCount": 0, ' "IsFavorite": false ' } ' ], ' "Status": 1, ' "ParentMessageId": 989436, ' "DistributionListId": 0, ' "DistributionListName": "", ' "BodyHistory": "", ' "ReadReceiptCallbackUrl": null, ' "SendGlobalNotifications": false ' } ' Dim UserName As String Dim AccountId As Integer Dim AccountName As String Dim AccountTitle As String Dim FirstName As String Dim LastName As String Dim LastSentOn As String Dim SendCount As Integer Dim IsFavorite As Boolean Dim Id As Integer = jsonData.IntOf("Id") Dim FromUserId As Integer = jsonData.IntOf("FromUserId") Dim FromMailBoxId As Integer = jsonData.IntOf("FromMailBoxId") Dim FromUserType As Integer = jsonData.IntOf("FromUserType") Dim FromUserName As String = jsonData.StringOf("FromUserName") Dim FromUserFullName As String = jsonData.StringOf("FromUserFullName") Dim FromUserAccountName As String = jsonData.StringOf("FromUserAccountName") Dim FromUserAccountTitle As String = jsonData.StringOf("FromUserAccountTitle") Dim ToUserId As Integer = jsonData.IntOf("ToUserId") Dim ToUserType As Integer = jsonData.IntOf("ToUserType") Dim ToUserMailboxId As String = jsonData.StringOf("ToUserMailboxId") Dim ToUserName As String = jsonData.StringOf("ToUserName") Dim ToUserFullName As String = jsonData.StringOf("ToUserFullName") Dim EmailAddress As String = jsonData.StringOf("EmailAddress") Dim Password As String = jsonData.StringOf("Password") Dim Subject As String = jsonData.StringOf("Subject") Dim PatientMedTunnelId As String = jsonData.StringOf("PatientMedTunnelId") Dim Body As String = jsonData.StringOf("Body") Dim DateReceived As String = jsonData.StringOf("DateReceived") Dim DisplayDateReceived As String = jsonData.StringOf("DisplayDateReceived") Dim ViewCount As Integer = jsonData.IntOf("ViewCount") Dim ViewedOn As String = jsonData.StringOf("ViewedOn") Dim AttachmentCount As Integer = jsonData.IntOf("AttachmentCount") Dim Status As Integer = jsonData.IntOf("Status") Dim ParentMessageId As Integer = jsonData.IntOf("ParentMessageId") Dim DistributionListId As Integer = jsonData.IntOf("DistributionListId") Dim DistributionListName As String = jsonData.StringOf("DistributionListName") Dim BodyHistory As String = jsonData.StringOf("BodyHistory") Dim ReadReceiptCallbackUrl As String = jsonData.StringOf("ReadReceiptCallbackUrl") Dim SendGlobalNotifications As Boolean = jsonData.BoolOf("SendGlobalNotifications") Dim i As Integer = 0 Dim count_i As Integer = jsonData.SizeOfArray("AttachmentNames") While i < count_i jsonData.I = i i = i + 1 End While i = 0 count_i = jsonData.SizeOfArray("AllRecipients") While i < count_i jsonData.I = i Id = jsonData.IntOf("AllRecipients[i].Id") UserName = jsonData.StringOf("AllRecipients[i].UserName") AccountId = jsonData.IntOf("AllRecipients[i].AccountId") AccountName = jsonData.StringOf("AllRecipients[i].AccountName") AccountTitle = jsonData.StringOf("AllRecipients[i].AccountTitle") FirstName = jsonData.StringOf("AllRecipients[i].FirstName") LastName = jsonData.StringOf("AllRecipients[i].LastName") EmailAddress = jsonData.StringOf("AllRecipients[i].EmailAddress") LastSentOn = jsonData.StringOf("AllRecipients[i].LastSentOn") SendCount = jsonData.IntOf("AllRecipients[i].SendCount") IsFavorite = jsonData.BoolOf("AllRecipients[i].IsFavorite") i = i + 1 End While |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.