DataFlex
DataFlex
MedTunnel: Get Mailbox Messages
See more MedTunnel Examples
Get the messages in the specified mailbox. The logged in user must have access to the mailbox.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoHttp
Variant vSbResponseBody
Handle hoSbResponseBody
Handle hoJResp
Integer iRespStatusCode
Integer iReturnCode
String sReturnCodeText
String sData
Handle hoJarr
Variant vJson
Handle hoJson
Integer iId
Integer iFromUserId
Integer iFromMailBoxId
Integer iFromUserType
String sFromUserName
String sFromUserFullName
String sFromUserAccountName
String sFromUserAccountTitle
Integer iToUserId
Integer iToUserType
String sToUserMailboxId
String sToUserName
String sToUserFullName
String sEmailAddress
String sPassword
String sSubject
String sPatientMedTunnelId
String sBody
String sDateReceived
String sDisplayDateReceived
Integer iViewCount
String sViewedOn
Integer iAttachmentCount
Integer iStatus
Integer iParentMessageId
Integer iDistributionListId
String sDistributionListName
String sBodyHistory
String sReadReceiptCallbackUrl
Boolean iSendGlobalNotifications
Integer j
Integer iCount_j
Integer iMessageId
String sName
String sDisplayName
Integer iSize
Boolean iWasViewed
String sLocation
String sUserName
Integer iAccountId
String sAccountName
String sAccountTitle
String sFirstName
String sLastName
String sLastSentOn
Integer iSendCount
Boolean iIsFavorite
Integer i
Integer iCount_i
String sTemp1
Move False To iSuccess
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
// 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
Send ComSetRequestHeader To hoHttp "Authorization" "PutAuthorizationTokenHere"
// The mailbox id is contained in the JSON response from the login.
Get ComSetUrlVar Of hoHttp "mailboxId" "36965" To iSuccess
Get ComSetUrlVar Of hoHttp "onlyMessagesWithAttachments" "false" To iSuccess
Get ComSetUrlVar Of hoHttp "lastMessageId" "0" To iSuccess
Get ComSetUrlVar Of hoHttp "startRow" "0" To iSuccess
Get ComSetUrlVar Of hoHttp "rowCount" "25" To iSuccess
Get ComSetUrlVar Of hoHttp "unReadOnly" "false" To iSuccess
Get ComSetUrlVar Of hoHttp "includeAllMailBoxes" "false" To iSuccess
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
Send CreateComObject of hoSbResponseBody
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComQuickGetSb Of hoHttp "https://server.medtunnel.com/medtunnelmsg/api/Message/GetMailBoxMessages?MailBoxId={$mailboxId}&OnlyMessagesWithAttachments={$onlyMessagesWithAttachments}&LastMessageId={$lastMessageId}&StartRow={$startRow}&RowCount={$rowCount}&UnReadOnly={$unReadOnly}&IncludeAllMailBoxes={$includeAllMailBoxes}" vSbResponseBody To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
If (Not(IsComObjectCreated(hoJResp))) Begin
Send CreateComObject of hoJResp
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
Set ComEmitCompact Of hoJResp To False
Showln "Response Body:"
Get ComEmit Of hoJResp To sTemp1
Showln sTemp1
Get ComLastStatus Of hoHttp To iRespStatusCode
Showln "Response Status Code = " iRespStatusCode
If (iRespStatusCode >= 400) Begin
Showln "Response Header:"
Get ComLastHeader Of hoHttp To sTemp1
Showln sTemp1
Showln "Failed."
Procedure_Return
End
// 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
Get ComIntOf Of hoJResp "ReturnCode" To iReturnCode
Get ComStringOf Of hoJResp "ReturnCodeText" To sReturnCodeText
Get ComStringOf Of hoJResp "Data" To sData
// The Data contains a JSON array, so load it into a Chilkat JSON array object.
Get Create (RefClass(cComChilkatJsonArray)) To hoJarr
If (Not(IsComObjectCreated(hoJarr))) Begin
Send CreateComObject of hoJarr
End
Get ComLoad Of hoJarr sData To iSuccess
Set ComEmitCompact Of hoJarr To False
Get ComEmit Of hoJarr To sTemp1
Showln sTemp1
// 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
// }
// ]
Move 0 To i
Get ComSize Of hoJarr To iCount_i
While (i < iCount_i)
Get ComObjectAt Of hoJarr i To vJson
If (IsComObject(vJson)) Begin
Get Create (RefClass(cComChilkatJsonObject)) To hoJson
Set pvComObject Of hoJson To vJson
End
Get ComIntOf Of hoJson "Id" To iId
Get ComIntOf Of hoJson "FromUserId" To iFromUserId
Get ComIntOf Of hoJson "FromMailBoxId" To iFromMailBoxId
Get ComIntOf Of hoJson "FromUserType" To iFromUserType
Get ComStringOf Of hoJson "FromUserName" To sFromUserName
Get ComStringOf Of hoJson "FromUserFullName" To sFromUserFullName
Get ComStringOf Of hoJson "FromUserAccountName" To sFromUserAccountName
Get ComStringOf Of hoJson "FromUserAccountTitle" To sFromUserAccountTitle
Get ComIntOf Of hoJson "ToUserId" To iToUserId
Get ComIntOf Of hoJson "ToUserType" To iToUserType
Get ComStringOf Of hoJson "ToUserMailboxId" To sToUserMailboxId
Get ComStringOf Of hoJson "ToUserName" To sToUserName
Get ComStringOf Of hoJson "ToUserFullName" To sToUserFullName
Get ComStringOf Of hoJson "EmailAddress" To sEmailAddress
Get ComStringOf Of hoJson "Password" To sPassword
Get ComStringOf Of hoJson "Subject" To sSubject
Get ComStringOf Of hoJson "PatientMedTunnelId" To sPatientMedTunnelId
Get ComStringOf Of hoJson "Body" To sBody
Get ComStringOf Of hoJson "DateReceived" To sDateReceived
Get ComStringOf Of hoJson "DisplayDateReceived" To sDisplayDateReceived
Get ComIntOf Of hoJson "ViewCount" To iViewCount
Get ComStringOf Of hoJson "ViewedOn" To sViewedOn
Get ComIntOf Of hoJson "AttachmentCount" To iAttachmentCount
Get ComIntOf Of hoJson "Status" To iStatus
Get ComIntOf Of hoJson "ParentMessageId" To iParentMessageId
Get ComIntOf Of hoJson "DistributionListId" To iDistributionListId
Get ComStringOf Of hoJson "DistributionListName" To sDistributionListName
Get ComStringOf Of hoJson "BodyHistory" To sBodyHistory
Get ComStringOf Of hoJson "ReadReceiptCallbackUrl" To sReadReceiptCallbackUrl
Get ComBoolOf Of hoJson "SendGlobalNotifications" To iSendGlobalNotifications
Move 0 To j
Get ComSizeOfArray Of hoJson "AttachmentNames" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJson To j
Get ComIntOf Of hoJson "AttachmentNames[j].MessageId" To iMessageId
Get ComIntOf Of hoJson "AttachmentNames[j].Id" To iId
Get ComStringOf Of hoJson "AttachmentNames[j].Name" To sName
Get ComStringOf Of hoJson "AttachmentNames[j].DisplayName" To sDisplayName
Get ComIntOf Of hoJson "AttachmentNames[j].Size" To iSize
Get ComBoolOf Of hoJson "AttachmentNames[j].WasViewed" To iWasViewed
Get ComStringOf Of hoJson "AttachmentNames[j].ViewedOn" To sViewedOn
Get ComIntOf Of hoJson "AttachmentNames[j].ViewCount" To iViewCount
Get ComStringOf Of hoJson "AttachmentNames[j].Location" To sLocation
Move (j + 1) To j
Loop
Move 0 To j
Get ComSizeOfArray Of hoJson "AllRecipients" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJson To j
Get ComIntOf Of hoJson "AllRecipients[j].Id" To iId
Get ComStringOf Of hoJson "AllRecipients[j].UserName" To sUserName
Get ComIntOf Of hoJson "AllRecipients[j].AccountId" To iAccountId
Get ComStringOf Of hoJson "AllRecipients[j].AccountName" To sAccountName
Get ComStringOf Of hoJson "AllRecipients[j].AccountTitle" To sAccountTitle
Get ComStringOf Of hoJson "AllRecipients[j].FirstName" To sFirstName
Get ComStringOf Of hoJson "AllRecipients[j].LastName" To sLastName
Get ComStringOf Of hoJson "AllRecipients[j].EmailAddress" To sEmailAddress
Get ComStringOf Of hoJson "AllRecipients[j].LastSentOn" To sLastSentOn
Get ComIntOf Of hoJson "AllRecipients[j].SendCount" To iSendCount
Get ComBoolOf Of hoJson "AllRecipients[j].IsFavorite" To iIsFavorite
Move (j + 1) To j
Loop
Send Destroy of hoJson
Move (i + 1) To i
Loop
End_Procedure