我想编一个电子邮件接收软件,我用POP3从邮件取回来了邮件的内容,但只能显示文本,请问如何把图片,附件等从中分离出来。

解决方案 »

  1.   

    这个问题我问过无数次了,可得到的都是base64解码
    如何解码!(愤怒)
      

  2.   

    #define DBASE64(a) (a>='A' && a<='Z')?a-'A': \
                       (a>='a'&&a<='z')?(a-'a')+26: \
                       (a>='0'&&a<='9')?(a-'0')+52: \
                       (a=='+')?(62):(a=='/')?(63): -1int CBase64Code::DecodeBase64(char * chInBuf, char *chOutBuf)
    {
    try
    {
    int nInLen = strlen(chInBuf);
    if(nInLen < 1)
    {
    chOutBuf = '\0';
    return 0;
    }
    else
    {
    int nValue = 0;
    int nFree = 0;
    int nInPos = 0 , nOutPos = 0;
    do
    {
    if(nFree >= 8)
    {
    chOutBuf[nOutPos ++] = nValue >> (nFree - 8);
    nFree -= 8;
    }
    else
    {
    if(nInPos < nInLen)
    {
    nValue <<= 6;
    int nTempValue = DBASE64((unsigned int)chInBuf[nInPos]);
    if(nTempValue < 0)
    return ERROR_WRONGCHARCODE;
    else
    {
    nValue |= nTempValue & 0x3f;
    nFree += 6;
    nInPos ++;
    }
    }
    else
    break;
    }
    }while(true);
    chOutBuf[nOutPos] = '\0';
    return nOutPos;
    }
    }
    catch(...)
    {
    return ERROR_EXCEPTION;
    }
    }