long lCount = pMessages->Count - 1;
// 遍历每封信
FILE *fp;
FILE *fp1;
FILE *fp2;
for(long i = 1; i <= lCount; i++)
{
// char *a = 0;
_bstr_t
a = pPOP3->GetMessageUID(i);
int alen = strlen(a);
pMessage = pMessages->Item[i];
custom1.bstrSubject = pMessage->Subject;
custom1.bstrFrom= pMessage->From;
custom1.bstrBody = pMessage->Body;
if ((fp1 = fopen("d:\\topgun.txt", "r")) == NULL)
{
exit(0);
}
fseek(fp1,1L*33*(i-1),SEEK_SET);//每输出一次,将从后30个字节开始读并与这次的比较
fread(DiskID, 30, 1, fp1);
fclose(fp1);
if(strcmp(a,DiskID)!=0)//DiskID和a比较
{
printf("(%d)Subject:%s, From:%s, Body:%s\r\n", i, (const char*)custom1.bstrSubject , (const char*)custom1.bstrFrom, (const char*)custom1.bstrBody); pMessage.Release();
}
else
{
printf("%s\r\n","No New Email!");
}
if ((fp = fopen("d:\\topgun.txt", "r+")) == NULL)//以追加的方式的写入文件
{
exit(0);
}
fseek(fp,1L*33*(i-1),SEEK_SET);
fwrite((const char*)a, alen, 1, fp);
fwrite("\r\n", sizeof(" "), 1, fp);//换行
fclose(fp);
// str.Format("insert into topgun (num) values (%d)", i);
sprintf(query,"insert into
chenlan(NO) values (%d);",i);//格式化的数据写入某个字符串
//sprintf(query,"insert into
chenlan (NO) values ("&i&")");
if(mysql_query(&mysql,query)!=0) //执行插入语句
{
printf("insert data error");
}
else
{
printf("insert data success");
}
mysql_close(&mysql);