Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using LumiSoft.Net.Mail;
- using LumiSoft.Net.MIME;
- using LumiSoft.Net.POP3.Client;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- namespace Mojna.WebApplication
- {
- public partial class WebForm1 : System.Web.UI.Page
- {
- private void receivemail()
- {
- POP3_Client clt = new POP3_Client();
- clt.Connect("sunucu", 110, false);
- clt.Authenticate("mail", "parola", true);
- clt.Timeout = int.MaxValue;
- List<MyVeriler> MailListesi = new List<MyVeriler>();
- foreach (POP3_ClientMessage item in clt.Messages)
- {
- Mail_Message mime = Mail_Message.ParseFromByte(item.MessageToByte());
- foreach (MIME_Entity entry in mime.Attachments)
- {
- string FileName = entry.ContentType.Param_Name;
- var data = ((MIME_b_SinglepartBase)entry.Body).Data;
- Response.Clear();
- Response.AddHeader("content-disposition", "attachment; filename=" + FileName);
- Response.OutputStream.Write(data, 0, data.Length);
- Response.End();
- }
- MailListesi.Add(new MyVeriler
- {
- MsgID = mime.MessageID,
- Konu = mime.Subject,
- Tarih = mime.Date.ToString("dd.MM.yyyy"),
- Gonderen = mime.From.ToString()
- });
- }
- this.GridView1.DataSource = MailListesi;
- this.GridView1.DataBind();
- }
- protected void Page_Load(object sender, EventArgs e)
- {
- receivemail();
- }
- }
- public class MyVeriler
- {
- public string MsgID { get; set; }
- public string Gonderen { get; set; }
- public string Tarih { get; set; }
- string _Konu;
- public string Konu
- {
- get
- {
- return _Konu;
- }
- set
- {
- _Konu = value.Length > 27 ? value.Substring(0, 27).ToString() + "..." : value;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment