[Repost] VC ++ to implement the batch export of Foxmail mail

xiaoxiao2021-03-06  39

introduction

In China, Foxmail has already become the preferred software for sending and receiving emails. It has already surpassed Outlook, but Foxmail is not perfect, especially in the export of mail in the mail, not too good, can only manually An aid will handle it, and if the number of letters is less, it can be dealt with, but if there is still a hundred emails, it is obviously quite difficult. To this end, this paper gives a method of exporting all messages in a mailing folder to the specified folder by analyzing the Foxmail mail clip file.

Foxmail mail clip composition analysis

In order to be able to program the processing of the FoxMail mail clip, you must first have a clear understanding of the Monitor's mail clip and internal mail. Go to the Foxmail installation directory, then send an email to yourself, after receiving, check the time attribute of each file under the installation directory, found that only the FmnMtk.dat file is the latest, but the file is far less than the email Therefore, it should be excluded. The subdirectory in the Mail folder corresponds to the Foxmail account. Enter files corresponding to the folder corresponding to an account, files in the folder, etc., respectively correspond to the recipient, sender, and send folders and waste boxes.

After clarifying the storage file corresponding to the mail clip, you can further analyze the internal structure of the mail clip by binary view software. Based on the current situation, it can determine that the mail in a mapping is stored in the same file, so this article can be converted to the bulk export issues of the mail clamp to separate each message from the mail clip file and output it to the outside. Document problem. In this way, in the analysis of the internal structure of the mail clip file, simply care about the boundaries of the two emails. Open a mail clip file, you can see that the start of a 16-party content is:

10 10 10 10 10 10 1111 11 1111 53 0D 0A52 65 74 7572 6e 2D 5061 74 68 3A 20 3C 7A 68

Here, starting a code is very standard, so you can speculate that the format header of the file or the format header of each message, searches the first 7 10 and 6 11 more than 13 characters in the file, which can be found that there are many identical characters And the searched characters adjacent to several characters "53", "0D", and "0a" also appear at the same time, and the following characters are not fixed, so the 16 characters can be further assumed to be the format head of the mail instead of the file. The format header (file format head is usually only once at the beginning of the file), and then the 16 characters in the mail clip file and record the number of times the search. It can be found that the number of emails in the mail clip can be found, and This number will change accordingly after deleting or adding a message. According to the above situation, "10 10 10 10 10 10 10 11 11 11 11 11 11 11 11 53 0D 0A" is the format head of the message, and the email can be separated according to this head. Program design implementation

After the composition structure of the Foxmail mail clip file, the extraction of the internal mail is not difficult. The programming center idea is the discrimination of the mail format, and exports the files located in the subsequent mail content data. To do this, you can search the ASCII code 10 (16) for all mail clips files. Once this character is found, 15 bytes may be the mail format header, then continue to determine if the 15 bytes will meet the mail. The format header, once a byte does not match, it indicates that it is not a message format head without processing, otherwise the mail data is written to the export file, and the previously opened export file is turned off:

// Read the character c = fgetc (fp1) from the mail clip file; while (! FeOf (fp1)) {// found that there is a header character with the separated character string, then enter the check () function for analysis IF (c == 0x10 Check (); // Generate output file name J ; filename.format ("% d", j); // Determine the storage path of the file to be exported CHAR EXEFULLPATH [MAX_PATH]; CSTRING STRPATH; GETMODULEFILENAME (Null, Exefullpath, Max_Path StrPath = cstring (exefullpath); strpath = strpath.Left (strpath.reversefind ('//')); strpath = strpath "// mail //" CSTRING (FileName) ".eml"; strcpy FullName, StrPath; // Open the export file in a write mode, if the file does not exist, the FP2 = FOPEN (Fullname, "W"); / / does not enter the end of the input file, is not the beginning of the characteristic string, Then write the character writes the output file while (! Feof (fp1) && (c = fgetc (fp1)))! = 0x10) FPUTC (C, FP2);}, for the judgment of the mail format header in the check () function Due to the completion of the 15 bytes of 0x10, it is discovered that it is not an email format header character to return, and it is returned immediately, and it is used as a message content data to process only after it is concluded as a mail format. File Close:

For (int I = 0; i <6; i ) {c = fgetc (fp1); // Returns IF (c! = 0x10) return;} for (i = 0; i <6);} for (i = 0; i <6);} for i ) {c = fgetc (fp1); // does not meet the separator string, then returns the content IF (C! = 0x11) return;} if ((c = fgetc (fp1)) = FGETC (FP1)) = = 0x53) IF ((c = fgetc (fp1)) == 0x0d) == 0x0a) == 0x0a) {c = fgetc (fp1); // completely conforming to the characteristic string, then the current message output After completion, turn off the output file fclose (fp2);

Since the design of this program is to automatically batch email, the amount of handling data is generally larger, in order to avoid program blocking, it can be placed in the thread. After experiment, the EML file exported by the above program can be identified and opened for the Outlook file, and the expected purpose is achieved.

summary

In this paper, by analyzing the composition structure of the Foxmail mail clip, it ultimately realizes the batch export of its mail, which greatly facilitates the backup, management of Foxmail mail, and has good support for different versions of Foxmail (current The latest version is 4.2, this method is applicable), so it is a practical mail assistance management tool. The code described herein is compiled by Microsoft Visual C 6.0 under Windows 2000 Professional.

转载请注明原文地址:https://www.9cbs.com/read-59929.html

New Post(0)