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
(C) MedTunnel: Get Mailbox MessagesSee more MedTunnel ExamplesGet the messages in the specified mailbox. The logged in user must have access to the mailbox. For more information, see https://server.medtunnel.com/apidocs/html/M_MedTunnelMsg_Controllers_MessageController_GetMailBoxMessages.htm
#include <C_CkHttp.h> #include <C_CkStringBuilder.h> #include <C_CkJsonObject.h> #include <C_CkJsonArray.h> void ChilkatSample(void) { HCkHttp http; BOOL success; HCkStringBuilder sbResponseBody; HCkJsonObject jResp; int respStatusCode; int ReturnCode; const char *ReturnCodeText; const char *Data; HCkJsonArray jarr; HCkJsonObject json; int Id; int FromUserId; int FromMailBoxId; int FromUserType; const char *FromUserName; const char *FromUserFullName; const char *FromUserAccountName; const char *FromUserAccountTitle; int ToUserId; int ToUserType; const char *ToUserMailboxId; const char *ToUserName; const char *ToUserFullName; const char *EmailAddress; const char *Password; const char *Subject; const char *PatientMedTunnelId; const char *Body; const char *DateReceived; const char *DisplayDateReceived; int ViewCount; const char *ViewedOn; int AttachmentCount; int Status; int ParentMessageId; int DistributionListId; const char *DistributionListName; const char *BodyHistory; const char *ReadReceiptCallbackUrl; BOOL SendGlobalNotifications; int j; int count_j; int MessageId; const char *Name; const char *DisplayName; int Size; BOOL WasViewed; const char *Location; const char *UserName; int AccountId; const char *AccountName; const char *AccountTitle; const char *FirstName; const char *LastName; const char *LastSentOn; int SendCount; BOOL IsFavorite; int i; int count_i; // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. http = CkHttp_Create(); // Implements the following CURL command: // curl -X GET -k // -H "Authorization:PutAuthorizationTokenHere" // https://server.medtunnel.com/medtunnelmsg/api/Message/GetMailBoxMessages?MailBoxId=623&OnlyMessagesWithAttachments=false&LastMessageId=27812&StartRow=3&RowCount=25&UnReadOnly=false&IncludeAllMailBoxes=false // Use the following online tool to generate HTTP code from a CURL command // Convert a cURL Command to HTTP Source Code CkHttp_SetRequestHeader(http,"Authorization","PutAuthorizationTokenHere"); // The mailbox id is contained in the JSON response from the login. CkHttp_SetUrlVar(http,"mailboxId","36965"); CkHttp_SetUrlVar(http,"onlyMessagesWithAttachments","false"); CkHttp_SetUrlVar(http,"lastMessageId","0"); CkHttp_SetUrlVar(http,"startRow","0"); CkHttp_SetUrlVar(http,"rowCount","25"); CkHttp_SetUrlVar(http,"unReadOnly","false"); CkHttp_SetUrlVar(http,"includeAllMailBoxes","false"); sbResponseBody = CkStringBuilder_Create(); success = CkHttp_QuickGetSb(http,"https://server.medtunnel.com/medtunnelmsg/api/Message/GetMailBoxMessages?MailBoxId={$mailboxId}&OnlyMessagesWithAttachments={$onlyMessagesWithAttachments}&LastMessageId={$lastMessageId}&StartRow={$startRow}&RowCount={$rowCount}&UnReadOnly={$unReadOnly}&IncludeAllMailBoxes={$includeAllMailBoxes}",sbResponseBody); if (success == FALSE) { printf("%s\n",CkHttp_lastErrorText(http)); CkHttp_Dispose(http); CkStringBuilder_Dispose(sbResponseBody); return; } jResp = CkJsonObject_Create(); CkJsonObject_LoadSb(jResp,sbResponseBody); CkJsonObject_putEmitCompact(jResp,FALSE); printf("Response Body:\n"); printf("%s\n",CkJsonObject_emit(jResp)); respStatusCode = CkHttp_getLastStatus(http); printf("Response Status Code = %d\n",respStatusCode); if (respStatusCode >= 400) { printf("Response Header:\n"); printf("%s\n",CkHttp_lastHeader(http)); printf("Failed.\n"); CkHttp_Dispose(http); CkStringBuilder_Dispose(sbResponseBody); CkJsonObject_Dispose(jResp); return; } // Sample JSON response: // (Sample code for parsing the JSON response is shown below) // { // "ReturnCode": 1, // "ReturnCodeText": "Success", // "Data": "[...]" // } // Sample code for parsing the JSON response... // Use the following online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON ReturnCode = CkJsonObject_IntOf(jResp,"ReturnCode"); ReturnCodeText = CkJsonObject_stringOf(jResp,"ReturnCodeText"); Data = CkJsonObject_stringOf(jResp,"Data"); // The Data contains a JSON array, so load it into a Chilkat JSON array object. jarr = CkJsonArray_Create(); CkJsonArray_Load(jarr,Data); CkJsonArray_putEmitCompact(jarr,FALSE); printf("%s\n",CkJsonArray_emit(jarr)); // Sample jsonArray content // See sample code for parsing this content below.. // [ // { // "Id": 989448, // "FromUserId": 36990, // "FromMailBoxId": 36965, // "FromUserType": 1, // "FromUserName": "joe@example", // "FromUserFullName": "Joe Smith", // "FromUserAccountName": "joe", // "FromUserAccountTitle": "Joe's Garage, Inc.", // "ToUserId": 36990, // "ToUserType": 1, // "ToUserMailboxId": "36965", // "ToUserName": "joe@example", // "ToUserFullName": "Joe Smith", // "EmailAddress": "", // "Password": "", // "Subject": "", // "PatientMedTunnelId": "", // "Body": "Test", // "DateReceived": "4/29/2021 2:48:22 PM", // "DisplayDateReceived": "Today 2:48 PM", // "ViewCount": 3, // "ViewedOn": "04/29/2021 2:52 PM", // "AttachmentCount": 1, // "AttachmentNames": [ // { // "MessageId": 989448, // "Id": 424857, // "Name": "starfish.jpg.35910fe9-4118-414c-a845-4d092ca6e784", // "DisplayName": "starfish.jpg", // "Size": 6229, // "WasViewed": true, // "ViewedOn": "4/29/2021 2:52:19 PM", // "ViewCount": 1, // "Location": "Default" // } // ], // "AllRecipients": [ // { // "Id": 989448, // "UserName": "joe@example", // "AccountId": 0, // "AccountName": "joe", // "AccountTitle": null, // "FirstName": "Joe", // "LastName": "Smith", // "EmailAddress": null, // "LastSentOn": null, // "SendCount": 0, // "IsFavorite": false // } // ], // "Status": 3, // "ParentMessageId": 989448, // "DistributionListId": 0, // "DistributionListName": "", // "BodyHistory": "", // "ReadReceiptCallbackUrl": null, // "SendGlobalNotifications": false // }, // { // "Id": 989445, // "FromUserId": 36990, // "FromMailBoxId": 36965, // "FromUserType": 1, // "FromUserName": "joe@example", // "FromUserFullName": "Joe Smith", // "FromUserAccountName": "joe", // "FromUserAccountTitle": "Joe's Garage, Inc.", // "ToUserId": 36990, // "ToUserType": 1, // "ToUserMailboxId": "36965", // "ToUserName": "joe@example", // "ToUserFullName": "Joe Smith", // "EmailAddress": "", // "Password": "", // "Subject": "", // "PatientMedTunnelId": "", // "Body": "Test", // "DateReceived": "4/29/2021 2:47:36 PM", // "DisplayDateReceived": "Today 2:47 PM", // "ViewCount": 1, // "ViewedOn": "", // "AttachmentCount": 1, // "AttachmentNames": [ // { // "MessageId": 989445, // "Id": 424856, // "Name": "starfish.jpg.c7dd04d8-43f2-4d86-af71-64f411bd5dfb", // "DisplayName": "starfish.jpg", // "Size": 6229, // "WasViewed": false, // "ViewedOn": "", // "ViewCount": 0, // "Location": "Default" // } // ], // "AllRecipients": [ // { // "Id": 989445, // "UserName": "joe@example", // "AccountId": 0, // "AccountName": "joe", // "AccountTitle": null, // "FirstName": "Joe", // "LastName": "Smith", // "EmailAddress": null, // "LastSentOn": null, // "SendCount": 0, // "IsFavorite": false // } // ], // "Status": 3, // "ParentMessageId": 989445, // "DistributionListId": 0, // "DistributionListName": "", // "BodyHistory": "", // "ReadReceiptCallbackUrl": null, // "SendGlobalNotifications": false // }, // { // "Id": 989436, // "FromUserId": 36990, // "FromMailBoxId": 36965, // "FromUserType": 1, // "FromUserName": "joe@example", // "FromUserFullName": "Joe Smith", // "FromUserAccountName": "joe", // "FromUserAccountTitle": "Joe's Garage, Inc.", // "ToUserId": 36990, // "ToUserType": 1, // "ToUserMailboxId": "36965", // "ToUserName": "joe@example", // "ToUserFullName": "Joe Smith", // "EmailAddress": "", // "Password": "", // "Subject": "", // "PatientMedTunnelId": "", // "Body": "Test", // "DateReceived": "4/29/2021 2:29:18 PM", // "DisplayDateReceived": "Today 2:29 PM", // "ViewCount": 1, // "ViewedOn": "", // "AttachmentCount": 0, // "AttachmentNames": [ // ], // "AllRecipients": [ // { // "Id": 989436, // "UserName": "joe@example", // "AccountId": 0, // "AccountName": "joe", // "AccountTitle": null, // "FirstName": "Joe", // "LastName": "Smith", // "EmailAddress": null, // "LastSentOn": null, // "SendCount": 0, // "IsFavorite": false // } // ], // "Status": 3, // "ParentMessageId": 989436, // "DistributionListId": 0, // "DistributionListName": "", // "BodyHistory": "", // "ReadReceiptCallbackUrl": null, // "SendGlobalNotifications": false // }, // { // "Id": 989432, // "FromUserId": 36990, // "FromMailBoxId": 36965, // "FromUserType": 1, // "FromUserName": "joe@example", // "FromUserFullName": "Joe Smith", // "FromUserAccountName": "joe", // "FromUserAccountTitle": "Joe's Garage, Inc.", // "ToUserId": 36990, // "ToUserType": 1, // "ToUserMailboxId": "36965", // "ToUserName": "joe@example", // "ToUserFullName": "Joe Smith", // "EmailAddress": "", // "Password": "", // "Subject": "", // "PatientMedTunnelId": "", // "Body": "Test", // "DateReceived": "4/29/2021 2:25:27 PM", // "DisplayDateReceived": "Today 2:25 PM", // "ViewCount": 1, // "ViewedOn": "", // "AttachmentCount": 0, // "AttachmentNames": [ // ], // "AllRecipients": [ // { // "Id": 989432, // "UserName": "joe@example", // "AccountId": 0, // "AccountName": "joe", // "AccountTitle": null, // "FirstName": "Joe", // "LastName": "Smith", // "EmailAddress": null, // "LastSentOn": null, // "SendCount": 0, // "IsFavorite": false // } // ], // "Status": 3, // "ParentMessageId": 989432, // "DistributionListId": 0, // "DistributionListName": "", // "BodyHistory": "", // "ReadReceiptCallbackUrl": null, // "SendGlobalNotifications": false // }, // { // "Id": 989251, // "FromUserId": 1, // "FromMailBoxId": 1, // "FromUserType": 100, // "FromUserName": "MedTunnel", // "FromUserFullName": "System Account", // "FromUserAccountName": "MedTunnel", // "FromUserAccountTitle": "", // "ToUserId": 36990, // "ToUserType": 1, // "ToUserMailboxId": "36965", // "ToUserName": "joe@example", // "ToUserFullName": "Joe Smith", // "EmailAddress": "", // "Password": "", // "Subject": "", // "PatientMedTunnelId": "", // "Body": "Welcome to MedTunnel! \r\n\r\nNow that you have signed up and activated your account, you are ready to start sending secure messages and documents using MedTunnel. So, what is the next step? It is recommended that you watch our training videos to learn how to use MedTunnel. There are 3 different client applications that you can use to access MedTunnel: \r\n\r\n1. If you are an administrator for a group, you should start out with the \u003cb\u003eGroup Account Administrators Video\u003c/b\u003e (\u003ca href=\"https://vimeo.com/104428633\" target=\"_blank\"\u003ehttps://vimeo.com/104428633\u003c/a\u003e). This video shows you the best practices for implementing MedTunnel into your practice, as well as how to add additional users. \r\n\r\n2. Next, watch the \u003cb\u003eMedTunnel Desktop App Video\u003c/b\u003e (\u003ca href=\"https://vimeo.com/103833157\" target=\"_blank\"\u003ehttps://vimeo.com/103833157\u003c/a\u003e). This video shows how to use the MedTunnel Desktop App - available as a free download for both PC and Mac. The Desktop App has 2 main features:\r\n\r\n\t- The \u003cb\u003ePrint-To-Send\u003c/b\u003e feature allows you to print from any application to a virtual printer to conveniently send documents.\r\n\r\n\t- The \u003cb\u003eAutoDownloader\u003c/b\u003e feature allows you to automatically download messages to your local hard drive for instant integration into your existing systems.\r\n\r\n3. Finally, there are two other client videos you can watch. The \u003cb\u003eWeb Client Demo Video\u003c/b\u003e (\u003ca href=\"https://vimeo.com/104434128\" target=\"_blank\"\u003ehttps://vimeo.com/104434128\u003c/a\u003e) shows you how to access MedTunnel via a browser on any device. The \u003cb\u003eMobile App Demo Video\u003c/b\u003e (\u003ca href=\"https://vimeo.com/104065728\" target=\"_blank\"\u003ehttps://vimeo.com/104065728\u003c/a\u003e) shows you how to access MedTunnel from our free Mobile App. \r\n\r\nHere are some useful links. \r\n\r\nMedTunnel Support Page: \u003ca href=\"http://www.medtunnel.com/support\" target=\"_blank\"\u003ehttp://www.medtunnel.com/support\u003c/a\u003e. The support page contains links to download the Desktop and Mobile Apps as well as other support related content. \r\n\r\nFAQs Page: \u003ca href=\"http://www.medtunnel.com/faqs\" target=\"_blank\"\u003ehttp://www.medtunnel.com/faqs\u003c/a\u003e. The FAQs page contains the most frequently asked questions about MedTunnel. \r\n\r\nIf you have any other questions or would like personalized service on using MedTunnel, you can contact us by simply logging in to your MedTunnel account and sending a message to MedTunnel ID: \u003cb\u003esupport\u003c/b\u003e. You can also contact us by sending an email to support@medtunnel.com. \r\n\r\nAgain - Welcome to MedTunnel! We truly hope you enjoy your MedTunnel experience!\r\n\r\nThe MedTunnel Team\r\n", // "DateReceived": "4/28/2021 10:58:30 PM", // "DisplayDateReceived": "04/28/2021 10:58 PM", // "ViewCount": 1, // "ViewedOn": "", // "AttachmentCount": 0, // "AttachmentNames": [ // ], // "AllRecipients": [ // { // "Id": 989251, // "UserName": "joe@example", // "AccountId": 0, // "AccountName": "joe", // "AccountTitle": null, // "FirstName": "Joe", // "LastName": "Smith", // "EmailAddress": null, // "LastSentOn": null, // "SendCount": 0, // "IsFavorite": false // } // ], // "Status": 3, // "ParentMessageId": 989251, // "DistributionListId": 0, // "DistributionListName": "", // "BodyHistory": "", // "ReadReceiptCallbackUrl": null, // "SendGlobalNotifications": false // } // ] // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat. // See this example explaining how this memory should be used: const char * functions. i = 0; count_i = CkJsonArray_getSize(jarr); while (i < count_i) { json = CkJsonArray_ObjectAt(jarr,i); Id = CkJsonObject_IntOf(json,"Id"); FromUserId = CkJsonObject_IntOf(json,"FromUserId"); FromMailBoxId = CkJsonObject_IntOf(json,"FromMailBoxId"); FromUserType = CkJsonObject_IntOf(json,"FromUserType"); FromUserName = CkJsonObject_stringOf(json,"FromUserName"); FromUserFullName = CkJsonObject_stringOf(json,"FromUserFullName"); FromUserAccountName = CkJsonObject_stringOf(json,"FromUserAccountName"); FromUserAccountTitle = CkJsonObject_stringOf(json,"FromUserAccountTitle"); ToUserId = CkJsonObject_IntOf(json,"ToUserId"); ToUserType = CkJsonObject_IntOf(json,"ToUserType"); ToUserMailboxId = CkJsonObject_stringOf(json,"ToUserMailboxId"); ToUserName = CkJsonObject_stringOf(json,"ToUserName"); ToUserFullName = CkJsonObject_stringOf(json,"ToUserFullName"); EmailAddress = CkJsonObject_stringOf(json,"EmailAddress"); Password = CkJsonObject_stringOf(json,"Password"); Subject = CkJsonObject_stringOf(json,"Subject"); PatientMedTunnelId = CkJsonObject_stringOf(json,"PatientMedTunnelId"); Body = CkJsonObject_stringOf(json,"Body"); DateReceived = CkJsonObject_stringOf(json,"DateReceived"); DisplayDateReceived = CkJsonObject_stringOf(json,"DisplayDateReceived"); ViewCount = CkJsonObject_IntOf(json,"ViewCount"); ViewedOn = CkJsonObject_stringOf(json,"ViewedOn"); AttachmentCount = CkJsonObject_IntOf(json,"AttachmentCount"); Status = CkJsonObject_IntOf(json,"Status"); ParentMessageId = CkJsonObject_IntOf(json,"ParentMessageId"); DistributionListId = CkJsonObject_IntOf(json,"DistributionListId"); DistributionListName = CkJsonObject_stringOf(json,"DistributionListName"); BodyHistory = CkJsonObject_stringOf(json,"BodyHistory"); ReadReceiptCallbackUrl = CkJsonObject_stringOf(json,"ReadReceiptCallbackUrl"); SendGlobalNotifications = CkJsonObject_BoolOf(json,"SendGlobalNotifications"); j = 0; count_j = CkJsonObject_SizeOfArray(json,"AttachmentNames"); while (j < count_j) { CkJsonObject_putJ(json,j); MessageId = CkJsonObject_IntOf(json,"AttachmentNames[j].MessageId"); Id = CkJsonObject_IntOf(json,"AttachmentNames[j].Id"); Name = CkJsonObject_stringOf(json,"AttachmentNames[j].Name"); DisplayName = CkJsonObject_stringOf(json,"AttachmentNames[j].DisplayName"); Size = CkJsonObject_IntOf(json,"AttachmentNames[j].Size"); WasViewed = CkJsonObject_BoolOf(json,"AttachmentNames[j].WasViewed"); ViewedOn = CkJsonObject_stringOf(json,"AttachmentNames[j].ViewedOn"); ViewCount = CkJsonObject_IntOf(json,"AttachmentNames[j].ViewCount"); Location = CkJsonObject_stringOf(json,"AttachmentNames[j].Location"); j = j + 1; } j = 0; count_j = CkJsonObject_SizeOfArray(json,"AllRecipients"); while (j < count_j) { CkJsonObject_putJ(json,j); Id = CkJsonObject_IntOf(json,"AllRecipients[j].Id"); UserName = CkJsonObject_stringOf(json,"AllRecipients[j].UserName"); AccountId = CkJsonObject_IntOf(json,"AllRecipients[j].AccountId"); AccountName = CkJsonObject_stringOf(json,"AllRecipients[j].AccountName"); AccountTitle = CkJsonObject_stringOf(json,"AllRecipients[j].AccountTitle"); FirstName = CkJsonObject_stringOf(json,"AllRecipients[j].FirstName"); LastName = CkJsonObject_stringOf(json,"AllRecipients[j].LastName"); EmailAddress = CkJsonObject_stringOf(json,"AllRecipients[j].EmailAddress"); LastSentOn = CkJsonObject_stringOf(json,"AllRecipients[j].LastSentOn"); SendCount = CkJsonObject_IntOf(json,"AllRecipients[j].SendCount"); IsFavorite = CkJsonObject_BoolOf(json,"AllRecipients[j].IsFavorite"); j = j + 1; } CkJsonObject_Dispose(json); i = i + 1; } CkHttp_Dispose(http); CkStringBuilder_Dispose(sbResponseBody); CkJsonObject_Dispose(jResp); CkJsonArray_Dispose(jarr); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.