Beispiel #1
0
        private void Ic_NewMessage(object sender, AE.Net.Mail.Imap.MessageEventArgs e)
        {
            //Check the message and send a reply
            if (ic == null)
            {
                ic = new ImapClient("imap.gmail.com", username, password, AuthMethods.Login, 993, true);
                ic.NewMessage += Ic_NewMessage;
            }
            AE.Net.Mail.MailMessage msg = ic.GetMessage(e.MessageCount - 1);   //Get the newest email

            switch (msg.Subject)
            {
                case "GetIP":  //Retrieve VNC info and send reply
                    {
                        Console.WriteLine($"GetIP command received from {msg.From.Address}");
                        string hostName = Dns.GetHostName();
                        var addrs = Dns.GetHostEntry(hostName);

                        string body = $"Host Name: {hostName}\n";

                        for (int i = 0; i < addrs.AddressList.Length; i++)
                        {
                            body += $"IPAddress #{i + 1}: {addrs.AddressList[i].ToString()}\n";
                        }

                        SendMessage(body, msg.From.Address);
                    }
                    break;
			case "Reset":
				{
					switch (PlatformInfo.RunningPlatform ()) {
					case Platform.Linux:
						Application.Restart ();
						break;
					case Platform.Windows:
						Process.Start (Application.ExecutablePath );
						Environment.Exit (0);
						break;
					}
				}
				break;
                case "Help":
                    {
                        Console.WriteLine($"Help command received from {msg.From.Address}");

                        string body = "Commands:\n";
                        body += "GetIP - Get IP Addresses\n";
					body += "Reset - Reset the connection\n";
                        SendMessage(body, msg.From.Address);
                    }
                    break;
            }

            ic.DeleteMessage(msg);
        }
 private MailMessage GetInputMailMessage(AE.Net.Mail.MailMessage message)
 {
     return new MailMessage
     {
         Date = message.Date,
         Sender = message.From,
         Receivers = message.To,
         Subject = message.Subject,
         Body = message.Body,
         UserAgent = GetUserAgent(message.Raw)
     };
 }
Beispiel #3
0
 public GmailMessage(AE.Net.Mail.MailMessage message)
 {
     Uid = long.Parse(message.Uid);
     Headers = message.Headers.ToDictionary(p => p.Key, p=> p.Value.Value);
     MessageDate = message.Date;
     MessageFlags = (Flags)(int)message.Flags;
     FromAddress = message.From.Address;
     FromDisplayName = message.From.DisplayName.Length > 0
         ? message.From.DisplayName
         : message.From.Address.Split("@".ToCharArray())[0];
     Subject = message.Subject;
     Body = message.Body ?? string.Empty;
 }
Beispiel #4
0
 public virtual void DeleteMessage(AE.Net.Mail.MailMessage msg)
 {
     DeleteMessage(msg.Uid);
 }
        public void MapMailMessage(System.Data.DataRow dr, AE.Net.Mail.MailMessage mmsg)
        {
            dr["bcc"] = GetAddresses(mmsg.Bcc);
            dr["body"] = mmsg.Body;
            dr["cc"] = GetAddresses(mmsg.Cc);
            dr["date"] = mmsg.Date;
            dr["from"] = mmsg.From != null ? mmsg.From.Address : "";
            dr["importance"] = mmsg.Importance.ToString();
            dr["replyto"] = GetAddresses(mmsg.ReplyTo);
            dr["sender"] = mmsg.Sender != null ? mmsg.Sender.Address : "";
            dr["size"] = mmsg.Size;
            dr["subject"] = mmsg.Subject;
            dr["to"] = GetAddresses(mmsg.To);
            dr["uid"] = mmsg.Uid;
            //dr["rawmessage"] = m.RawBody;
            //dr["base64emlmessage"] = m.Base64Body;
            dr["attachmentscount"] = mmsg.Attachments != null ? mmsg.Attachments.Count : 0;


        }