pcmaker

Untitled

Nov 29th, 2012
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.27 KB | None | 0 0
  1. using LumiSoft.Net.Mail;
  2. using LumiSoft.Net.MIME;
  3. using LumiSoft.Net.POP3.Client;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Web;
  9. using System.Web.UI;
  10. using System.Web.UI.WebControls;
  11.  
  12. namespace Mojna.WebApplication
  13. {
  14.     public partial class WebForm1 : System.Web.UI.Page
  15.     {
  16.         private void receivemail()
  17.         {
  18.             POP3_Client clt = new POP3_Client();
  19.             clt.Connect("sunucu", 110, false);
  20.             clt.Authenticate("mail", "parola", true);
  21.             clt.Timeout = int.MaxValue;
  22.  
  23.             List<MyVeriler> MailListesi = new List<MyVeriler>();
  24.  
  25.             foreach (POP3_ClientMessage item in clt.Messages)
  26.             {
  27.                 Mail_Message mime = Mail_Message.ParseFromByte(item.MessageToByte());
  28.  
  29.                 foreach (MIME_Entity entry in mime.Attachments)
  30.                 {
  31.                     string FileName = entry.ContentType.Param_Name;
  32.                     var data = ((MIME_b_SinglepartBase)entry.Body).Data;
  33.                     Response.Clear();
  34.                     Response.AddHeader("content-disposition", "attachment; filename=" + FileName);
  35.                     Response.OutputStream.Write(data, 0, data.Length);
  36.                     Response.End();
  37.                 }
  38.  
  39.                 MailListesi.Add(new MyVeriler
  40.                 {
  41.                     MsgID = mime.MessageID,
  42.                     Konu = mime.Subject,
  43.                     Tarih = mime.Date.ToString("dd.MM.yyyy"),
  44.                     Gonderen = mime.From.ToString()
  45.                 });
  46.             }
  47.  
  48.             this.GridView1.DataSource = MailListesi;
  49.             this.GridView1.DataBind();
  50.         }
  51.  
  52.         protected void Page_Load(object sender, EventArgs e)
  53.         {
  54.             receivemail();
  55.         }
  56.  
  57.     }
  58.     public class MyVeriler
  59.     {
  60.         public string MsgID { get; set; }
  61.         public string Gonderen { get; set; }
  62.         public string Tarih { get; set; }
  63.         string _Konu;
  64.         public string Konu
  65.         {
  66.             get
  67.             {
  68.                 return _Konu;
  69.             }
  70.             set
  71.             {
  72.                 _Konu = value.Length > 27 ? value.Substring(0, 27).ToString() + "..." : value;
  73.             }
  74.         }
  75.     }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment