// ---------------------- signal events ----------------------------------
 // ( if user code contains an "OnEvent" method. )
 void SignalConnectedEvent(MailEventArgs InArgs)
 {
     if (Connected != null)
     {
         Connected(this, InArgs);
     }
 }
 void SignalAuthenticatedEvent(MailEventArgs InArgs)
 {
     if (Authenticated != null)
     {
         Authenticated(this, InArgs);
     }
 }
 void SignalEndDataSendEvent(MailEventArgs InArgs)
 {
     if (EndDataSend != null)
     {
         EndDataSend(this, InArgs);
     }
 }
 void SignalDisconnectedEvent(MailEventArgs InArgs)
 {
     if (Disconnected != null)
     {
         Disconnected(this, InArgs);
     }
 }
Exemple #5
0
        /// <summary>
        /// This patches mailbox read method on gamelocation and allow call custom logic
        /// for NPC Adventures mail letters only. For other mails call vanilla logic.
        /// </summary>
        /// <param name="__instance">Game location</param>
        /// <returns></returns>
        private static bool Before_mailbox(ref GameLocation __instance)
        {
            try
            {
                if (Game1.mailbox.Count <= 0)
                {
                    return(true);
                }

                var letter = Game1.mailbox.First();

                if (letter != null && letter.StartsWith("npcAdventures."))
                {
                    string[]      parsedLetter = letter.Split('.');
                    MailEventArgs args         = new MailEventArgs
                    {
                        FullLetterKey = letter,
                        LetterKey     = parsedLetter.Length > 1 ? parsedLetter[1] : null,
                        Mailbox       = Game1.player.mailbox,
                        Player        = Game1.player,
                    };

                    Instance.Events.FireMailOpen(__instance, args);

                    return(false);
                }
            }
            catch (Exception ex)
            {
                Instance.LogFailure(ex, nameof(Before_mailbox));
            }

            return(true);
        }
 void SignalStartDataSendEvent(MailEventArgs InArgs)
 {
     if (StartDataSend != null)
     {
         StartDataSend(this, InArgs);
     }
 }
Exemple #7
0
        public string OncheckMail(object sender, MailEventArgs e)
        {
            string result = null;

            foreach (User user in users)
            {
                if (user.Mail == e.Emailtext)
                {
                    result = user.Mail;
                }
            }
            return(result);
        }
        /// <summary>
        /// Vygeneruje event oznamujuci poziadavku na odoslanie emailovej spravy
        /// </summary>
        /// <param name="e">MailEventArgs</param>
        protected virtual void OnMailMessage(MailEventArgs e)
        {
            MailEventHandler handler = this._mailEvent;

            if (handler != null)
            {
                if (this._mailEventAsync)
                {
                    handler.BeginInvoke(this, e, null, null);
                }
                else
                {
                    handler(this, e);
                }
            }
        }
Exemple #9
0
 private void SendMessage(object sender, MailEventArgs mailEvent)
 {
     try
     {
         mailMessage = new MailMessage
         {
             From = new MailAddress("*****@*****.**")
         };
         foreach (var rec in mailEvent.Recievers)
         {
             mailMessage.To.Add(rec);
         }
         mailMessage.Body    = mailEvent.Message;
         mailMessage.Subject = mailEvent.Subject;
         client.Send(mailMessage);
     }
     catch (Exception ex)
     {
         StaticEventHandler.Log(System.Diagnostics.TraceLevel.Error, "Error Sending mail", MethodBase.GetCurrentMethod(), ex);
     }
 }
Exemple #10
0
 public static void SendMail(MailEventArgs mailEventArgs)
 {
     SendMailEvent?.Invoke(null, mailEventArgs);
 }
Exemple #11
0
        private void ReceiveMailHandler(object sender, MailEventArgs e)
        {
            // This method is called when OnReceiveMail is fired inside MailListener.

            /* CHECK HERE IF ENTERPRISE EXISTS AND SHOULD THIS MAIL BE FORWARDED OR NOT */

            MailAddress from = new MailAddress(e.From, "NAME OF SENDER");
            MailAddress to = new MailAddress(e.To);
            MailMessage message = new MailMessage(from, to);
            message.Subject = e.To;
            message.Body = e.Body;
            foreach (var attachment in e.Attachments)
            {
                // SOMEHOW CONVERT attachment (object) to Mail.Attachment.
                message.Attachments.Add((Attachment)attachment);
            }

            SendMail(message);
        }