using coldfusion + javamail to read .eml file and show image attachments
843834Feb 5 2008 — edited Feb 5 2008I'm trying read a .eml and then display attachments in this file using Javamail and Coldfusion.
Here's some of my code:
<cffunction name="init" output="true">
<cfargument name="filename" required="true">
<cfset variables.emlFilenameandPath = "D:\site\Dev\test\#arguments.filename#" />
<cfset variables.oProps = createObject("Java", "java.util.Properties")>
<cfset variables.oProps.init()>
<cfset variables.temp = oProps.put("mail.host", "smtp.test.com")>
<cfset variables.temp2 = oProps.put("mail.transport.protocol", "smtp")>
<cfset variables.mSession = createObject("Java", "javax.mail.Session")>
<cfset variables.objSession = mSession.getInstance(oProps)>
<cfset variables.FileInputStream = CreateObject("Java", "java.io.FileInputStream") />
<cfset variables.FileInputStream.init("#emlFilenameandPath#") />
<cfset variables.oMail = createObject("Java", "javax.mail.internet.MimeMessage").init(objSession,FileInputStream)>
<cfreturn this/>
</cffunction>
<cffunction name="getAttachments" output="true">
<cfset content = oMail.getContent()>
Where I need to go from here, I'm not sure. It looks like the getBodyPart and getContentType and getFileName functions might be what I need, but I'm not sure and I'm having a lot of trouble using these functions without Coldfusion telling me these functions don't exist. Anyone else done something like this with Javamail and Coldfusion?