SQL Server
SQL Server
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 SQL Server Downloads
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
DECLARE @success int
SELECT @success = 0
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @http int
EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
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
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Authorization', 'PutAuthorizationTokenHere'
-- The mailbox id is contained in the JSON response from the login.
EXEC sp_OAMethod @http, 'SetUrlVar', @success OUT, 'mailboxId', '36965'
EXEC sp_OAMethod @http, 'SetUrlVar', @success OUT, 'onlyMessagesWithAttachments', 'false'
EXEC sp_OAMethod @http, 'SetUrlVar', @success OUT, 'lastMessageId', '0'
EXEC sp_OAMethod @http, 'SetUrlVar', @success OUT, 'startRow', '0'
EXEC sp_OAMethod @http, 'SetUrlVar', @success OUT, 'rowCount', '25'
EXEC sp_OAMethod @http, 'SetUrlVar', @success OUT, 'unReadOnly', 'false'
EXEC sp_OAMethod @http, 'SetUrlVar', @success OUT, 'includeAllMailBoxes', 'false'
DECLARE @sbResponseBody int
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT
EXEC sp_OAMethod @http, 'QuickGetSb', @success OUT, '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 = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
RETURN
END
DECLARE @jResp int
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jResp OUT
EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody
EXEC sp_OASetProperty @jResp, 'EmitCompact', 0
PRINT 'Response Body:'
EXEC sp_OAMethod @jResp, 'Emit', @sTmp0 OUT
PRINT @sTmp0
DECLARE @respStatusCode int
EXEC sp_OAGetProperty @http, 'LastStatus', @respStatusCode OUT
PRINT 'Response Status Code = ' + @respStatusCode
IF @respStatusCode >= 400
BEGIN
PRINT 'Response Header:'
EXEC sp_OAGetProperty @http, 'LastHeader', @sTmp0 OUT
PRINT @sTmp0
PRINT 'Failed.'
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
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
DECLARE @ReturnCode int
EXEC sp_OAMethod @jResp, 'IntOf', @ReturnCode OUT, 'ReturnCode'
DECLARE @ReturnCodeText nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ReturnCodeText OUT, 'ReturnCodeText'
DECLARE @Data nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Data OUT, 'Data'
-- The Data contains a JSON array, so load it into a Chilkat JSON array object.
DECLARE @jarr int
EXEC @hr = sp_OACreate 'Chilkat.JsonArray', @jarr OUT
EXEC sp_OAMethod @jarr, 'Load', @success OUT, @Data
EXEC sp_OASetProperty @jarr, 'EmitCompact', 0
EXEC sp_OAMethod @jarr, 'Emit', @sTmp0 OUT
PRINT @sTmp0
-- 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
-- }
-- ]
DECLARE @json int
DECLARE @Id int
DECLARE @FromUserId int
DECLARE @FromMailBoxId int
DECLARE @FromUserType int
DECLARE @FromUserName nvarchar(4000)
DECLARE @FromUserFullName nvarchar(4000)
DECLARE @FromUserAccountName nvarchar(4000)
DECLARE @FromUserAccountTitle nvarchar(4000)
DECLARE @ToUserId int
DECLARE @ToUserType int
DECLARE @ToUserMailboxId nvarchar(4000)
DECLARE @ToUserName nvarchar(4000)
DECLARE @ToUserFullName nvarchar(4000)
DECLARE @EmailAddress nvarchar(4000)
DECLARE @Password nvarchar(4000)
DECLARE @Subject nvarchar(4000)
DECLARE @PatientMedTunnelId nvarchar(4000)
DECLARE @Body nvarchar(4000)
DECLARE @DateReceived nvarchar(4000)
DECLARE @DisplayDateReceived nvarchar(4000)
DECLARE @ViewCount int
DECLARE @ViewedOn nvarchar(4000)
DECLARE @AttachmentCount int
DECLARE @Status int
DECLARE @ParentMessageId int
DECLARE @DistributionListId int
DECLARE @DistributionListName nvarchar(4000)
DECLARE @BodyHistory nvarchar(4000)
DECLARE @ReadReceiptCallbackUrl nvarchar(4000)
DECLARE @SendGlobalNotifications int
DECLARE @j int
DECLARE @count_j int
DECLARE @MessageId int
DECLARE @Name nvarchar(4000)
DECLARE @DisplayName nvarchar(4000)
DECLARE @Size int
DECLARE @WasViewed int
DECLARE @Location nvarchar(4000)
DECLARE @UserName nvarchar(4000)
DECLARE @AccountId int
DECLARE @AccountName nvarchar(4000)
DECLARE @AccountTitle nvarchar(4000)
DECLARE @FirstName nvarchar(4000)
DECLARE @LastName nvarchar(4000)
DECLARE @LastSentOn nvarchar(4000)
DECLARE @SendCount int
DECLARE @IsFavorite int
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAGetProperty @jarr, 'Size', @count_i OUT
WHILE @i < @count_i
BEGIN
EXEC sp_OAMethod @jarr, 'ObjectAt', @json OUT, @i
EXEC sp_OAMethod @json, 'IntOf', @Id OUT, 'Id'
EXEC sp_OAMethod @json, 'IntOf', @FromUserId OUT, 'FromUserId'
EXEC sp_OAMethod @json, 'IntOf', @FromMailBoxId OUT, 'FromMailBoxId'
EXEC sp_OAMethod @json, 'IntOf', @FromUserType OUT, 'FromUserType'
EXEC sp_OAMethod @json, 'StringOf', @FromUserName OUT, 'FromUserName'
EXEC sp_OAMethod @json, 'StringOf', @FromUserFullName OUT, 'FromUserFullName'
EXEC sp_OAMethod @json, 'StringOf', @FromUserAccountName OUT, 'FromUserAccountName'
EXEC sp_OAMethod @json, 'StringOf', @FromUserAccountTitle OUT, 'FromUserAccountTitle'
EXEC sp_OAMethod @json, 'IntOf', @ToUserId OUT, 'ToUserId'
EXEC sp_OAMethod @json, 'IntOf', @ToUserType OUT, 'ToUserType'
EXEC sp_OAMethod @json, 'StringOf', @ToUserMailboxId OUT, 'ToUserMailboxId'
EXEC sp_OAMethod @json, 'StringOf', @ToUserName OUT, 'ToUserName'
EXEC sp_OAMethod @json, 'StringOf', @ToUserFullName OUT, 'ToUserFullName'
EXEC sp_OAMethod @json, 'StringOf', @EmailAddress OUT, 'EmailAddress'
EXEC sp_OAMethod @json, 'StringOf', @Password OUT, 'Password'
EXEC sp_OAMethod @json, 'StringOf', @Subject OUT, 'Subject'
EXEC sp_OAMethod @json, 'StringOf', @PatientMedTunnelId OUT, 'PatientMedTunnelId'
EXEC sp_OAMethod @json, 'StringOf', @Body OUT, 'Body'
EXEC sp_OAMethod @json, 'StringOf', @DateReceived OUT, 'DateReceived'
EXEC sp_OAMethod @json, 'StringOf', @DisplayDateReceived OUT, 'DisplayDateReceived'
EXEC sp_OAMethod @json, 'IntOf', @ViewCount OUT, 'ViewCount'
EXEC sp_OAMethod @json, 'StringOf', @ViewedOn OUT, 'ViewedOn'
EXEC sp_OAMethod @json, 'IntOf', @AttachmentCount OUT, 'AttachmentCount'
EXEC sp_OAMethod @json, 'IntOf', @Status OUT, 'Status'
EXEC sp_OAMethod @json, 'IntOf', @ParentMessageId OUT, 'ParentMessageId'
EXEC sp_OAMethod @json, 'IntOf', @DistributionListId OUT, 'DistributionListId'
EXEC sp_OAMethod @json, 'StringOf', @DistributionListName OUT, 'DistributionListName'
EXEC sp_OAMethod @json, 'StringOf', @BodyHistory OUT, 'BodyHistory'
EXEC sp_OAMethod @json, 'StringOf', @ReadReceiptCallbackUrl OUT, 'ReadReceiptCallbackUrl'
EXEC sp_OAMethod @json, 'BoolOf', @SendGlobalNotifications OUT, 'SendGlobalNotifications'
SELECT @j = 0
EXEC sp_OAMethod @json, 'SizeOfArray', @count_j OUT, 'AttachmentNames'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @json, 'J', @j
EXEC sp_OAMethod @json, 'IntOf', @MessageId OUT, 'AttachmentNames[j].MessageId'
EXEC sp_OAMethod @json, 'IntOf', @Id OUT, 'AttachmentNames[j].Id'
EXEC sp_OAMethod @json, 'StringOf', @Name OUT, 'AttachmentNames[j].Name'
EXEC sp_OAMethod @json, 'StringOf', @DisplayName OUT, 'AttachmentNames[j].DisplayName'
EXEC sp_OAMethod @json, 'IntOf', @Size OUT, 'AttachmentNames[j].Size'
EXEC sp_OAMethod @json, 'BoolOf', @WasViewed OUT, 'AttachmentNames[j].WasViewed'
EXEC sp_OAMethod @json, 'StringOf', @ViewedOn OUT, 'AttachmentNames[j].ViewedOn'
EXEC sp_OAMethod @json, 'IntOf', @ViewCount OUT, 'AttachmentNames[j].ViewCount'
EXEC sp_OAMethod @json, 'StringOf', @Location OUT, 'AttachmentNames[j].Location'
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @json, 'SizeOfArray', @count_j OUT, 'AllRecipients'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @json, 'J', @j
EXEC sp_OAMethod @json, 'IntOf', @Id OUT, 'AllRecipients[j].Id'
EXEC sp_OAMethod @json, 'StringOf', @UserName OUT, 'AllRecipients[j].UserName'
EXEC sp_OAMethod @json, 'IntOf', @AccountId OUT, 'AllRecipients[j].AccountId'
EXEC sp_OAMethod @json, 'StringOf', @AccountName OUT, 'AllRecipients[j].AccountName'
EXEC sp_OAMethod @json, 'StringOf', @AccountTitle OUT, 'AllRecipients[j].AccountTitle'
EXEC sp_OAMethod @json, 'StringOf', @FirstName OUT, 'AllRecipients[j].FirstName'
EXEC sp_OAMethod @json, 'StringOf', @LastName OUT, 'AllRecipients[j].LastName'
EXEC sp_OAMethod @json, 'StringOf', @EmailAddress OUT, 'AllRecipients[j].EmailAddress'
EXEC sp_OAMethod @json, 'StringOf', @LastSentOn OUT, 'AllRecipients[j].LastSentOn'
EXEC sp_OAMethod @json, 'IntOf', @SendCount OUT, 'AllRecipients[j].SendCount'
EXEC sp_OAMethod @json, 'BoolOf', @IsFavorite OUT, 'AllRecipients[j].IsFavorite'
SELECT @j = @j + 1
END
EXEC @hr = sp_OADestroy @json
SELECT @i = @i + 1
END
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
EXEC @hr = sp_OADestroy @jarr
END
GO