tags:

views:

646

answers:

4

Hi,

For my new project which has email module.i need to show all the email information on web.when i m making a call to server i m getting the base64 encoded mime data. after applying base64 decoding technique i m getting the mime data as follows:

/*****************Mime data start *******************************/

From [email protected] Tue Jun 23 12:01:02 2009
Date: Tue, 23 Jun 2009 12:01:02 +0530
From: Prashant R Naik <[email protected]>
To: [email protected]
Subject: This is a test mail
Message-ID: <[email protected]>
Reply-To: Prashant R Naik <[email protected]>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="ReaqsoxgOBHFXBhH"
Content-Disposition: inline
User-Agent: Mutt/1.5.18 (2008-05-17)
Status: RO
Content-Length: 1912
Lines: 52


--ReaqsoxgOBHFXBhH
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Test mail.
Initiated by prashant

Regards,
-- 
Prashant R Naik
Principal Technologist | Symbian & Web2.0
Geodesic Limited | www.geodesic.com
Tel: +91-80-66551000

--ReaqsoxgOBHFXBhH
Content-Type: image/gif
Content-Disposition: attachment; filename="trash.gif"
Content-Transfer-Encoding: base64

R0lGODlhEAAQANUoADJ8wTqU2DmR1TqV2DN9wTSBxTWFyTaGyTJ9wTWGyTaKzjmS1TOAxTuV
2DaFyTN8wDiN0jiO0jSAxTeKzjqS1DN8wTqR1TWFyjB4vTOBxTmO0TmS1DaKzTeJzTqV1zSA
xDJ8wDqS1TeKzTF4vDF4vTiO0f///zuX2gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAACgALAAA
AAAQABAAAAaDQNRpSCwWhcakcsk8mZ5Qpik5pUKvT2W1uDVWp+BiYNAImAZmz/lcDoQEFoFp
QTFtTPKFQLCAREolJiURJhCCJhqAJRMiIhwmjSYdJgqUjQoODgkJJgecBp0mBgYXBx8ZBQxY
UAUSDAUACLEPDwgEAAAEIBUEtygkIyMkwMMYw8EjKEEAOw==

--ReaqsoxgOBHFXBhH
Content-Type: image/jpeg
Content-Disposition: attachment; filename="bx.jpg"
Content-Transfer-Encoding: base64

/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAAR
CAAUAAoDAREAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAn/xAAYEAEAAwEAAAAAAAAA
AAAAAAAAGWen5//EABQBAQAAAAAAAAAAAAAAAAAAAAD/xAAUEQEAAAAAAAAAAAAAAAAAAAAA
/9oADAMBAAIRAxEAPwCb4AJHym0Vp3PQJTaK07noJHgA/9k=

--ReaqsoxgOBHFXBhH
Content-Type: image/png
Content-Disposition: attachment; filename="day_bg.png"
Content-Transfer-Encoding: base64

iVBORw0KGgoAAAANSUhEUgAAAGQAAAApCAYAAADDJIzmAAAABmJLR0QA/wD/AP+gvaeTAAAA
CXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH2AwCCS0kTriU2QAAAB10RVh0Q29tbWVudABD
cmVhdGVkIHdpdGggVGhlIEdJTVDvZCVuAAAAXElEQVR42u3bQQEAMAgDMZiqiZtP5AwbfeQk
NO/WvPtLMR0TABEQIAICRECACAgQAREQIAICRECACAgQAREQIAICRECACAgQAREQIAICRECA
CAgQARGQ7NpPPasFT+0FZPjBRwYAAAAASUVORK5CYII=

--ReaqsoxgOBHFXBhH--

/*****************Mime data end *******************************/

now the problem is i have to parse this data and use it in my application.since this data is not a xml so it difficult to parse it (because parsing with some tag is easy).so any one who knows how to parse mime data help be.i m using erlang to parse this data.

Thank you in advance

A: 

Erlang for web apps? Wow, you do know how to make life hard for yourself! :)

Anyhow, here's what you need:

http://code.google.com/p/mimeparse/

Don't give me the rep, give it to Google. I searched for "erlang parse mime message".

the.jxc
mimeparse is for parsing mime types, not complete messages.
Tim Fletcher
+2  A: 

gen_smtp and erlang_smtp contain code for parsing mime messages.

Tim Fletcher
but seems not useful in my context any ways thanx
Abhimanyu
+1  A: 

Ah, sorry... OK. Then in the spirit of Gollum and the riddle game, I can offer only "Yaws or nothing" which isn't very fair, because it's really two guesses in one.

http://yaws.hyber.org/yapp_intro.yaws

However, rolling your own mime parser isn't very hard. Get the "Boundary" and split the message on lines matching "--". Then for each chunks, parse headings until you get to CRLF, CRLF. Then your content starts.

I know that responses that say "use a different language" are generally unhelpful. I'm going to guess that you didn't chosen Erlang as "the language which will make this job easier", so I'm guessing there's an external constraint. Would you care to share the reason that Erlang is your preferred solution language? :)

the.jxc
A: 

You can use mime4j lib. Here is example, how to use it: http://www.akvilon-soft.com/archives/16

Den.Lunev