Ejemplo n.º 1
0
 public IEnumerable <SmtpMessage> Get()
 {
     App.Current.WaiteForEndOfAllSessions();
     return(Directory.GetFiles(App.Current.MailFolderPath, "*.eml")
            .Select(path => SmtpMessage.CreateFrom(path))
            .OrderByDescending(m => m.Date));
 }
Ejemplo n.º 2
0
 public SmtpMessage Get(Guid id)
 {
     App.Current.WaiteForEndOfAllSessions();
     return(Directory.GetFiles(App.Current.MailFolderPath, "*.eml")
            .Select(path => SmtpMessage.CreateFrom(path))
            .First(a => a.Id == id));
 }
Ejemplo n.º 3
0
        public static SmtpMessage CreateFrom(string path)
        {
            var msg = new SmtpMessage();

            msg.Load(path);
            return(msg);
        }
Ejemplo n.º 4
0
        public void Delete(Guid id)
        {
            var pathToDelete = Directory.GetFiles(App.Current.MailFolderPath, "*.eml")
                               .Select(path => new { path, SmtpMessage.CreateFrom(path).Id })
                               .First(a => a.Id == id)
                               .path;

            File.Delete(pathToDelete);

            // notify via SignalR
            var hubContext = SignalR.GlobalHost.ConnectionManager.GetHubContext <SmtpServerHub>();

            SmtpServerHub.NotifyRemoveMessage(id, hubContext.Clients);
        }
Ejemplo n.º 5
0
 public static object ToSimpleFormat(this SmtpMessage msg)
 {
     return(new
     {
         msg.Id,
         From = msg.From != null?msg.From.ToString() : "",
                    To = msg.To.Select(_ => _.ToString()).ToArray(),
                    CC = msg.CC.Select(_ => _.ToString()).ToArray(),
                    msg.Subject,
                    msg.Date,
                    msg.Body,
                    Attachments = msg.Attachments.Select(_ => _.Name).ToArray()
     });
 }
Ejemplo n.º 6
0
        public void Delete()
        {
            var hubContext = SignalR.GlobalHost.ConnectionManager.GetHubContext <SmtpServerHub>();

            Directory.GetFiles(App.Current.MailFolderPath, "*.eml")
            .Select(path => new { path, SmtpMessage.CreateFrom(path).Id })
            .ToList()
            .ForEach(m =>
            {
                File.Delete(m.path);

                // notify via SignalR
                SmtpServerHub.NotifyRemoveMessage(m.Id, hubContext.Clients);
            });
        }
Ejemplo n.º 7
0
 internal void FireReceiveMessage(SmtpMessage message)
 {
     this.ReceiveMessage(this, new ReceiveMessageEventArgs(message));
 }
 public ReceiveMessageEventArgs(SmtpMessage message)
 {
     this.Message = message;
 }
 public ReceiveMessageEventArgs(SmtpMessage message)
 {
     this.Message = message;
 }
Ejemplo n.º 10
0
 public static void NotifyReceiveMessage(SmtpMessage message, IHubConnectionContext clients)
 {
     clients.All.ReceiveMessage(message.ToSimpleFormat());
 }
Ejemplo n.º 11
0
 internal void FireReceiveMessage(SmtpMessage message)
 {
     this.ReceiveMessage(this, new ReceiveMessageEventArgs(message));
 }
Ejemplo n.º 12
0
 public static SmtpMessage CreateFrom(string path)
 {
     var msg = new SmtpMessage();
     msg.Load(path);
     return msg;
 }