How can I Convert MIME content to string

421 views
Skip to first unread message

barnbx

unread,
Feb 27, 2015, 8:39:06 AM2/27/15
to intersystems...@googlegroups.com

My organization recently enrolled in Microsoft HealthVault project for our stage 2 certification. In order to facilitate smooth and secure data transmission, we elected to use a third party vendor called DataMotion as our HISP (Health Information Service Provider). We decided to connect with DataMotion through Web Services. Using their wsdl xml document, we were able to generate their proxy classes. They also provided us with their SDK which was written in VB.Net as reference guide to assist us in implementing the same thing in cache. Using their wsdl doc, we were able to build our proxy classes in cache. However, we have been trying unsuccessfully to send MIME messages with attachments. What we noticed from their code is that, they're using Microsoft CDO Messaging object to setup their contents which contains MIME message with attachment. These MIME messages are converted into string before they're transmitted. Their sendMIMEMessage proxy method only except two parameters, a session key and a string message content. We have been unsuccessful in finding out how to do this with cache %Net.MimePart object. We tried transmitting our message by attaching our files through the use of cache %SOAP.WebClient instance method called "Attachments", but it didn't work. It returns an error message stating that media type is unsupported. Can anyone steer me in right direction on how to accomplish this? Below are examples of what I am trying to achieve.

 

Below is the method they are invoking in their vb.net code
Public Function ConvertCDOtoString(ByVal CDOMsg As CDO.Message) As String
        Dim strMessage As String
        'Convert CDO Message to ADO Stream
        Dim objADO As ADODB.Stream
        objADO = CDOMsg.GetStream
        objADO.Type = ADODB.StreamTypeEnum.adTypeBinary
        'Convert ADO Stream to String
        strMessage = System.Text.Encoding.ASCII.GetString(objADO.Read)
        objADO = Nothing
        Return strMessage
    End Function
 
This is what I am trying to do to accomplish the same thing above in cache
s file=##class(%Stream.FileCharacter).%New()
s file.Filename="c:\from-client\"_filename
s mimepart=##class(%Net.MIMEPart).%New()
Do mimepart.SetHeader("Content-Transfer-Encoding","7bit")
d mimepart.SetHeader("From",FromEMail)
d mimepart.SetHeader("To",ToEMail)
d mimepart.SetHeader("Subject",subj)
d mimepart.SetHeader("MIME-Version","1.0")
d mimepart.SetHeader("X-Mailer","MailBee.NET 8.0.4.428")
d mimepart.SetHeader("Content-Type","text/plain; charset="_"""us-ascii""")
s mimepart.Body=file
Do ..wsOref.Attachments.Insert(mimepart)
s status=..wsOref.SendMIMEMessage(..SessionKey,mimepart) //This didn't work because mimepart object is being passed instead of string. How can I convert this to string?
 
 

Jason Warner

unread,
Feb 27, 2015, 12:41:43 PM2/27/15
to intersystems...@googlegroups.com, barnbx
You probably need to look at %Net.MIMEWriter to write the document to a stream that you can convert to a string.

http://docs.intersystems.com/cache20131/csp/documatic/%25CSP.Documatic.cls?PAGE=CLASS&LIBRARY=%25SYS&CLASSNAME=%25Net.MIMEWriter

Jason
--
--
Caché, Ensemble, DeepSee

---
You received this message because you are subscribed to the Google Groups "Caché, Ensemble, DeepSee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to intersystems-publi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages