Click here to Skip to main content
12,763,515 members (33,555 online)
Rate this:
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
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.
Rate this: bad
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:"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.

Rate this: bad
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);

                       contenuPieceJointe = ConversionBase64("\n"+contenuPieceJointe.Trim()+"\n");
                       StreamWriter swPj = new StreamWriter(repertoireMail + "\\" + nooomPieceJointe, false);

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170217.1 | Last Updated 14 Nov 2012
Copyright © CodeProject, 1999-2017
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