Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

PowerBuilder Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
Jira
Lightspeed
MYOB
Magento
Mailgun
Mastercard

MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(PowerBuilder) MedTunnel: Send Message with File Attachment

See more MedTunnel Examples

Demonstrates the MedTunnel SendMessage method to send a message with a file attachment to one or more recipients.

For more information, see https://server.medtunnel.com/apidocs/html/M_MedTunnelMsg_Controllers_MessageController_SendMessage.htm

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_Req
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
integer li_ReturnCode
string ls_ReturnCodeText
string ls_Data
oleobject loo_JsonData
integer li_MessageId
string ls_Name
string ls_DisplayName
integer li_Size
integer li_WasViewed
string ls_Location
string ls_UserName
integer li_AccountId
string ls_AccountName
string ls_AccountTitle
string ls_FirstName
string ls_LastName
string ls_LastSentOn
integer li_SendCount
integer li_IsFavorite
integer li_Id
integer li_FromUserId
integer li_FromMailBoxId
integer li_FromUserType
string ls_FromUserName
string ls_FromUserFullName
string ls_FromUserAccountName
string ls_FromUserAccountTitle
integer li_ToUserId
integer li_ToUserType
string ls_ToUserMailboxId
string ls_ToUserName
string ls_ToUserFullName
string ls_EmailAddress
string ls_Password
string ls_Subject
string ls_PatientMedTunnelId
string ls_Body
string ls_DateReceived
string ls_DisplayDateReceived
integer li_ViewCount
string ls_ViewedOn
integer li_AttachmentCount
integer li_Status
integer li_ParentMessageId
integer li_DistributionListId
string ls_DistributionListName
string ls_BodyHistory
string ls_ReadReceiptCallbackUrl
integer li_SendGlobalNotifications
integer i
integer li_Count_i

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat_9_5_0.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

// 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"
//         -F "file1=@qa_data/jpg/starfish.jpg"

// Use the following online tool to generate HTTP code from a CURL command
// Convert a cURL Command to HTTP Source Code

loo_Req = create oleobject
li_rc = loo_Req.ConnectToNewObject("Chilkat_9_5_0.HttpRequest")

loo_Req.HttpVerb = "POST"
loo_Req.Path = "/MedTunnelMsg/api/Message/SendMessage"
loo_Req.ContentType = "multipart/form-data"

loo_Req.AddParam("ApplicationId","yourApplicationId")
loo_Req.AddParam("LocationId","yourLocationId")
loo_Req.AddParam("MedTunnelId","yourMedTunnelId")
loo_Req.AddParam("MedTunnelPassword","yourMedTunnelPassword")
loo_Req.AddParam("To","recipientsMedTunnelId")
loo_Req.AddParam("Body","Test")

li_Success = loo_Req.AddFileForUpload2("file1","qa_data/jpg/starfish.jpg","application/octet-stream")

loo_Req.AddHeader("Expect","100-continue")

loo_Resp = loo_Http.SynchronousRequest("server.medtunnel.com",443,1,loo_Req)
if loo_Http.LastMethodSuccess = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_Req
    return
end if

loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

loo_Resp.GetBodySb(loo_SbResponseBody)
loo_JResp = create oleobject
li_rc = loo_JResp.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Resp.StatusCode
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Resp.Header
    Write-Debug "Failed."
    destroy loo_Resp
    destroy loo_Http
    destroy loo_Req
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

destroy loo_Resp

// 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

li_ReturnCode = loo_JResp.IntOf("ReturnCode")
ls_ReturnCodeText = loo_JResp.StringOf("ReturnCodeText")
ls_Data = loo_JResp.StringOf("Data")

// Load the Data into another JSON object and parse..
loo_JsonData = create oleobject
li_rc = loo_JsonData.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_JsonData.Load(ls_Data)
loo_JsonData.EmitCompact = 0
Write-Debug loo_JsonData.Emit()

// {
//   "Id": 989448,
//   "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:48:22 PM",
//   "DisplayDateReceived": "04/29/2021  2:48 PM",
//   "ViewCount": 0,
//   "ViewedOn": "",
//   "AttachmentCount": 1,
//   "AttachmentNames": [
//     {
//       "MessageId": 989448,
//       "Id": 424857,
//       "Name": "starfish.jpg.35910fe9-4118-414c-a845-4d092ca6e784",
//       "DisplayName": "starfish.jpg",
//       "Size": 6229,
//       "WasViewed": false,
//       "ViewedOn": "",
//       "ViewCount": 0,
//       "Location": "Default"
//     }
//   ],
//   "AllRecipients": [
//     {
//       "Id": 989448,
//       "UserName": "...",
//       "AccountId": 0,
//       "AccountName": "...",
//       "AccountTitle": "",
//       "FirstName": "...",
//       "LastName": "...",
//       "EmailAddress": "",
//       "LastSentOn": "",
//       "SendCount": 0,
//       "IsFavorite": false
//     }
//   ],
//   "Status": 0,
//   "ParentMessageId": 989448,
//   "DistributionListId": 0,
//   "DistributionListName": "",
//   "BodyHistory": "",
//   "ReadReceiptCallbackUrl": null,
//   "SendGlobalNotifications": false
// }

li_Id = loo_JsonData.IntOf("Id")
li_FromUserId = loo_JsonData.IntOf("FromUserId")
li_FromMailBoxId = loo_JsonData.IntOf("FromMailBoxId")
li_FromUserType = loo_JsonData.IntOf("FromUserType")
ls_FromUserName = loo_JsonData.StringOf("FromUserName")
ls_FromUserFullName = loo_JsonData.StringOf("FromUserFullName")
ls_FromUserAccountName = loo_JsonData.StringOf("FromUserAccountName")
ls_FromUserAccountTitle = loo_JsonData.StringOf("FromUserAccountTitle")
li_ToUserId = loo_JsonData.IntOf("ToUserId")
li_ToUserType = loo_JsonData.IntOf("ToUserType")
ls_ToUserMailboxId = loo_JsonData.StringOf("ToUserMailboxId")
ls_ToUserName = loo_JsonData.StringOf("ToUserName")
ls_ToUserFullName = loo_JsonData.StringOf("ToUserFullName")
ls_EmailAddress = loo_JsonData.StringOf("EmailAddress")
ls_Password = loo_JsonData.StringOf("Password")
ls_Subject = loo_JsonData.StringOf("Subject")
ls_PatientMedTunnelId = loo_JsonData.StringOf("PatientMedTunnelId")
ls_Body = loo_JsonData.StringOf("Body")
ls_DateReceived = loo_JsonData.StringOf("DateReceived")
ls_DisplayDateReceived = loo_JsonData.StringOf("DisplayDateReceived")
li_ViewCount = loo_JsonData.IntOf("ViewCount")
ls_ViewedOn = loo_JsonData.StringOf("ViewedOn")
li_AttachmentCount = loo_JsonData.IntOf("AttachmentCount")
li_Status = loo_JsonData.IntOf("Status")
li_ParentMessageId = loo_JsonData.IntOf("ParentMessageId")
li_DistributionListId = loo_JsonData.IntOf("DistributionListId")
ls_DistributionListName = loo_JsonData.StringOf("DistributionListName")
ls_BodyHistory = loo_JsonData.StringOf("BodyHistory")
ls_ReadReceiptCallbackUrl = loo_JsonData.StringOf("ReadReceiptCallbackUrl")
li_SendGlobalNotifications = loo_JsonData.BoolOf("SendGlobalNotifications")
i = 0
li_Count_i = loo_JsonData.SizeOfArray("AttachmentNames")
do while i < li_Count_i
    loo_JsonData.I = i
    li_MessageId = loo_JsonData.IntOf("AttachmentNames[i].MessageId")
    li_Id = loo_JsonData.IntOf("AttachmentNames[i].Id")
    ls_Name = loo_JsonData.StringOf("AttachmentNames[i].Name")
    ls_DisplayName = loo_JsonData.StringOf("AttachmentNames[i].DisplayName")
    li_Size = loo_JsonData.IntOf("AttachmentNames[i].Size")
    li_WasViewed = loo_JsonData.BoolOf("AttachmentNames[i].WasViewed")
    ls_ViewedOn = loo_JsonData.StringOf("AttachmentNames[i].ViewedOn")
    li_ViewCount = loo_JsonData.IntOf("AttachmentNames[i].ViewCount")
    ls_Location = loo_JsonData.StringOf("AttachmentNames[i].Location")
    i = i + 1
loop
i = 0
li_Count_i = loo_JsonData.SizeOfArray("AllRecipients")
do while i < li_Count_i
    loo_JsonData.I = i
    li_Id = loo_JsonData.IntOf("AllRecipients[i].Id")
    ls_UserName = loo_JsonData.StringOf("AllRecipients[i].UserName")
    li_AccountId = loo_JsonData.IntOf("AllRecipients[i].AccountId")
    ls_AccountName = loo_JsonData.StringOf("AllRecipients[i].AccountName")
    ls_AccountTitle = loo_JsonData.StringOf("AllRecipients[i].AccountTitle")
    ls_FirstName = loo_JsonData.StringOf("AllRecipients[i].FirstName")
    ls_LastName = loo_JsonData.StringOf("AllRecipients[i].LastName")
    ls_EmailAddress = loo_JsonData.StringOf("AllRecipients[i].EmailAddress")
    ls_LastSentOn = loo_JsonData.StringOf("AllRecipients[i].LastSentOn")
    li_SendCount = loo_JsonData.IntOf("AllRecipients[i].SendCount")
    li_IsFavorite = loo_JsonData.BoolOf("AllRecipients[i].IsFavorite")
    i = i + 1
loop


destroy loo_Http
destroy loo_Req
destroy loo_SbResponseBody
destroy loo_JResp
destroy loo_JsonData

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.