Click here to Skip to main content
Sign Up to vote bad
good
See more: C#
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 13-Nov-12 4:17am

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.

2 solutions

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
  Permalink  
sorry I've forgeot tsend to you the part of so here it is
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();
                   }
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Christian Graus 478
1 Ron Beyer 306
2 Tadit Dash 253
3 samadhan_kshirsagar 229
4 OriginalGriff 198
0 Sergey Alexandrovich Kryukov 7,041
1 Prasad_Kulkarni 3,815
2 OriginalGriff 3,557
3 _Amy 3,372
4 CPallini 3,034


Advertise | Privacy | Mobile
Web03 | 2.6.130619.1 | Last Updated 14 Nov 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid