掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
XE2標準搭載のIndy10で添付ファイルを保存するには? (ID:41526)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
コードを整理したところ、初歩的バグが多数あったので、 直しましたが、まだダウンロードに失敗します。 少しずつ原因が見えてきて、自分の技量不足が、 最大の要因っぽいです。 以下、現在のコードです。 どなたかお知恵をお貸しいただけると助かりますm(__)m。 void __fastcall TForm1::Button3Click(TObject *Sender) { //メールを受信する TIdMessage* msg = new TIdMessage(NULL); TIdEMailAddressItem* item = msg->Recipients->Add(); //1件だけ試し受信 bool result = IdPOP31->Retrieve(5049, msg); //メールの番号は1から if (result) { StringGrid1->Cells[1][1] = msg->Subject; StringGrid1->Cells[2][1] = msg->Body->Text; StringGrid1->Cells[3][1] = msg->Date; StringGrid1->Cells[4][1] = msg->From->Text; StringGrid1->Cells[5][1] = item->Address; StringGrid1->Cells[6][1] = msg->Headers->Text; int i = 1; while ("" != msg->MessageParts->Items[i]->FileName) { try { TIdAttachmentFile* attached = new TIdAttachmentFile( msg->MessageParts, msg->MessageParts->Items[i]->FileName); //ファイルのパス StringGrid1->Cells[7][1] = StringGrid1->Cells[7][1] + msg->MessageParts->Items[i]->FileName; attached->SaveToFile("d:\\" + msg->MessageParts->Items[i]->FileName); } catch (int) { } i += 1; } } else { MessageDlg("メールの受信に失敗しました。", mtError, TMsgDlgButtons() << mbOK, 0); } }
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.