Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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 5:17am
Comments
joshrduncan2012 at 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 at 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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
0 OriginalGriff 385
1 Sergey Alexandrovich Kryukov 329
2 CPallini 270
3 DamithSL 214
4 Maciej Los 192
0 OriginalGriff 5,515
1 DamithSL 4,451
2 Maciej Los 3,902
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,175


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 14 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100