全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1706
推到 Plurk!
推到 Facebook!

請問我該怎麼讀取POP下載來的Mail的內容(對不起我問題真多..)

答題得分者是:gemi0305
a8960905
一般會員


發表:30
回覆:47
積分:20
註冊:2003-09-19

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-09-28 17:16:10 IP:61.222.xxx.xxx 未訂閱
請問我該怎麼讀取POP下載來的Mail的內容 例如 NMPOP31->Summary->From 可以讀出這方郵件 是從哪來的但我應該如何才能讀出這封郵件的 內容呢?? 拜託...^^ 大家抱歉喔...偶訴呆呆滴新手問題多多 呵呵
gemi0305
版主


發表:81
回覆:564
積分:629
註冊:2003-05-11

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-09-28 17:26:13 IP:61.224.xxx.xxx 未訂閱
如果你真的很急的話,先看一下這個吧, 自己先試試看~我以前也是用這改一改,到一到,就可以了~ 先k一下吧~
   
To recreate this example, you will need to create a new blank CBuilder   application.    Place 6 TEdits, a TMemo, a TCheckBox, 2 TButtons, and a TNMPOP3 on the Form.    Component Descriptions:
Edit1: Host
Edit2: User ID
Edit3: Password
Edit4: Attachment Path
Edit5: From (Person that sent the E-Mail)
Edit6: Subject of the E-Mail
Memo1: Message Body
Button1: Connect/Disconnect
Button2: Get Mail Message
CheckBox1: Delete message after reading    Insert the following code into Button1's OnClick event:    void __fastcall TForm1::Button1Click(TObject *Sender)    {      if (NMPOP31->Connected)        NMPOP31->Disconnect();      else        {          NMPOP31->Host = Edit1->Text;          NMPOP31->UserID = Edit2->Text;          NMPOP31->Password = Edit3->Text;          NMPOP31->DeleteOnRead = CheckBox1->Checked;          NMPOP31->AttachFilePath = Edit4->Text;          NMPOP31->Connect();        }    }    When Button1 gets clicked, if there is a connection with the remote 
host, the Disconnect method is executed to close the connection. If 
there is no connection present, the Host property, which specifies 
the mail server to connect to, is set to the value in Edit1. The 
UserID property, which specifies the user name to log in as, is set
 to the vlaue in Edit2. The Password property, which should 
correspond with the UserID property, is set to the value in Edit3. 
If CheckBox1 is checked (true), then messages are deleted as they 
are retrieved by the GetMailMessage method, since the DeleteOnRead 
property is set to the value of CheckBox1.Checked. the 
AttachFilePath property is set to the value in Edit4, and the 
Connect method establishes a connection with the remote host.    Insert the following test into NMPOP31's OnConnect method:    void __fastcall TForm1::NMPOP31Connect(TObject *Sender)    {      if (NMPOP31->MailCount > 0)        ShowMessage(IntToStr(NMPOP31->MailCount) " messages in your mailbox");      else        ShowMessage("No messages waiting");    }    When the client connects to the mail host, the OnConnect event is 
called. If there are messages    waiting on the server, a message box pops up displaying the number 
stored in the MailCount property, stating how many messages are 
waiting on the server. If there are no messages, a box is displayed 
stating that there are no messages.    Insert the following code into Button2's OnClick event:    void __fastcall TForm1::Button2Click(TObject *Sender)    {      AnsiString S;      int M;      if (NMPOP31->MailCount > 0)        {          if (InputQuery("Retrieve an E-Mail message", "Which message? (1-" IntToStr(NMPOP31->MailCount) ")", S))            {              M = StrToIntDef(S, -1);              if ((M < 0) || (M > NMPOP31->MailCount))                ShowMessage("Invalid message index");              else                NMPOP31->GetMailMessage(M);            }        }      else        ShowMessage("No Messages to Get");    }    When Button2 is clicked, if there are messages on the server 
(NMPOP31.MailCount > 0), the InputQuery function requests a message 
number to retrieve. If the OK button in clicked, the number typed in 
is checked for validity with the actual number of messages. If the 
specified mail number is invalid, a message box is displayed saying 
the message doesn't exist. If the specified message exists, it is 
retrieved using the GetMailMessage method.    Insert the following code into NMPOP31's OnRetrieveEnd event:    void __fastcall TForm1::NMPOP31RetrieveEnd(TObject *Sender)    {      Memo1->Text = NMPOP31->MailMessage->Body->Text;      Edit6->Text = NMPOP31->MailMessage->Subject;      Edit5->Text = NMPOP31->MailMessage->From;    }    The OnRetrieveEnd event is called when a message has completed being 
retrieved from the remote host. In this case, Memo1 is set to the 
Body of the MailMessage property, displaying the contents of the 
message.Edit6 is set to the Subject of the MailMessage property, 
displaying the subject line of the message. Edit5 is set to the 
sender of the message, stored in the From property of the 
MailMessage property    Insert the following code into NMPOP31's OnDecodeStart event:    void __fastcall TForm1::NMPOP31DecodeStart(AnsiString &FileName);
{
  AnsiString S;
  S = FileName;
  if (InputQuery("Save File Attachment", "Filename?", S))
    FileName = S;
}    When a file attachment begins decoding, the OnDecodeStart event is 
called. In this example, the InputQuery function is used to retrieve 
a file name. If the Ok button is clicked, the FileName parameter is 
changed to the new value entered in the input box. 
國泰平安 發表人 - Gemi0305 於 2003/09/28 17:29:10
gemi0305
版主


發表:81
回覆:564
積分:629
註冊:2003-05-11

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-09-28 17:37:11 IP:61.224.xxx.xxx 未訂閱
再來就是請你去玩一玩那個bcb裡面的demo檔~ bcb6在 C:\Program Files\Borland\CBuilder6\Examples\FastNet\POP3的目錄下~ bcb5在 C:\Program Files\Borland\CBuilder5\Examples\FastNet\Pop3目錄~    有個Demo的程式可以讓你試, 裡面很多程式可以直接改一改就可以拿來用了~ 國泰平安
gemi0305
版主


發表:81
回覆:564
積分:629
註冊:2003-05-11

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-09-28 17:51:14 IP:61.224.xxx.xxx 未訂閱
這是那個demo檔的片段程式, NMPOP31->GetMailMessage(int index);是get你的信箱中第幾封信件, get之後, Memo1->Lines->Assign(NMPOP31->MailMessage->Body); 就可以把信的內容show在Memo1上了~     
  
  NMPOP31->GetMailMessage(StrToInt(Edit5->Text));
  Edit6->Text = NMPOP31->MailMessage->From;
  Edit7->Text = NMPOP31->MailMessage->Subject;
  Edit9->Text = NMPOP31->MailMessage->MessageId;
  Memo2->Lines->Assign(NMPOP31->MailMessage->Head);
  Memo1->Lines->Assign(NMPOP31->MailMessage->Body);
  if (NMPOP31->MailMessage->Attachments->Text != "")
    ShowMessage("Attachments:\n" NMPOP31->MailMessage->Attachments->Text);        
國泰平安
系統時間:2024-05-16 1:27:07
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!