Click here to Skip to main content
15,884,979 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everybody i have create a program to read an E_mail from Server so when i attempt to extract the attachemetn file and convert it into original base64 it doesn't work
Can someon help me please
Posted
Comments
joshrduncan2012 13-Nov-12 10:21am    
We can't help you unless you show us what you have done so far so we can better assist where the problem might be.
Christian Graus 13-Nov-12 10:33am    
You should read the guide on how to ask questions. Or just ask yourself, if someone was asking me this, what would I want to know ? Would you expect to be shown code ? Told what 'doesn't work' means ? Your question as it stands is only attractive to people who like insolvable puzzles.

There is no need to "convert it into original base64" — so called "attachment" is an e-mail part usually encoded in base64 already (or it could be just plain text, for text parts), in a multi-part messages. Open any mail block with a plain text editor and see by yourself.

Please see these CodeProject articles: http://www.codeproject.com/search.aspx?doctypeid=1&q=pop3+mail+"C%23"[^].

Even if you don't use POP3, you will find the rest of the solution, the one you are missing: how to parse the multipart mail message and extract parts. This way, you can extract "attachments".

And your "does not work" is not informative — if you still cannot resolve it, show your code using "Improve question" above.

—SA
 
Share this answer
 
sorry I've forgeot tsend to you the part of so here it is
C#
if (blocMail.IndexOf("Content-Disposition: attachment") != -1)
                   {
                       int debut = blocMail.IndexOf("Content-Disposition: attachment");
                       int longeur = blocMail.Length;
                       string pieceJointe = blocMail.Substring(debut);
                       string[] pj = pieceJointe.Split('\n');
                       string[] nomPj = pj[1].Split('"');
                       string nooomPieceJointe = nomPj[1].ToString();
                       int debutPj = pieceJointe.IndexOf(nooomPieceJointe)+nooomPieceJointe.Length+1;

                       int fin = pieceJointe.IndexOf("\n--");
                       string pieceJointee = pieceJointe.Substring(fin);
                       //int debSub = (pieceJointe.Length - debutPj);
                       int finSub = (pieceJointe.Length - fin);
                       int longSub= pieceJointe.Length-(debutPj+finSub );
                       string contenuPieceJointe = pieceJointe.Substring(debutPj,longSub);

                       //string content = blocMail.Substring(debut, fin);
                       //MessageBox.Show(contenuPieceJointe);


                       contenuPieceJointe = ConversionBase64("\n"+contenuPieceJointe.Trim()+"\n");
                       StreamWriter swPj = new StreamWriter(repertoireMail + "\\" + nooomPieceJointe, false);
                       swPj.WriteLine(contenuPieceJointe);
                       swPj.Close();
                   }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900