コード例 #1
0
ファイル: TestController.cs プロジェクト: Fonden/Natteravnene
        public ActionResult PreViewEmailMessagNotification(string name)
        {
            Person P = new Person
            {
                FirstName = "Hej",
                FamilyName = "EfetrHej"
            };
            
            
            MessagNotification email = new MessagNotification();
            // set up the email ...
            email.To = "*****@*****.**";
            email.Subject = "Test emne";
            email.ReplyTo = "dan@Taxbol";
            email.Message = "em længere beskede der måske kan indholde <strong>Html</strong>";
            email.Link = "http://eteelrande";
            email.FromPerson = P;
            //email.folder = reposetory.GetFolder(new Guid("9b93e5c0-7caf-e411-bf26-c485084553de"));
            //email.Person = reposetory.GetPerson(new Guid("983504df-3e8b-4af7-a54d-308090a74a02"));
            //email.message = "test besked på at det virker atgsepråer";
            //email.ReplyToList.Add("*****@*****.**");
            email.Send();
            return new EmailViewResult(email);

        }
コード例 #2
0
ファイル: Processes.cs プロジェクト: Fonden/Natteravnene
        /// <summary>
        /// Sends notification for new messages in the system
        /// </summary>
        public void SendMessages()
        {
            List<MessageReciver> Recivers = reposetory.ProcessMessageNotification();

            foreach (MessageReciver R in Recivers)
            {
                if (R.Message.Type == MessageType.shortMessage && R.Reciver != null && !string.IsNullOrWhiteSpace(R.Reciver.Mobile))
                {


#if DUMMYTEXT
                    ITextMessage SMSGateway = TextServiceProviderFactory.GetTextServiceProviderrInstance("NR.Infrastructure.DummyTextGateway", null, null);
#else
                    ITextMessage SMSGateway = TextServiceProviderFactory.GetTextServiceProviderrInstance(null, null, null);
#endif
                    if (R.Message != null && R.Message.Sender != null && string.IsNullOrWhiteSpace(R.Message.Sender.Mobile))
                    {
                        SMSGateway.FromText = General.SystemTextMessagesFrom;
                    }
                    else
                    {
                        SMSGateway.From = R.Message.Sender;
                    }
                    SMSGateway.Message = R.Message.Body + "\n\r---\n\r" + General.MessageNotificationFooter;
                    SMSGateway.Recipient = new List<Person> { R.Reciver };

                    if (HandshakeUrl != null && HandshakeUrl.Contains("##")) SMSGateway.HandShakeUrl = HandshakeUrl.Replace("##", SMSGateway.TextId);

                    if (SMSGateway.Send())
                    {
                        reposetory.MarkSent(R);
                        LogFile.Write("Send Message >>> ShortSend  Mobile: (" + R.Reciver.Mobile + ")");
                    }
                    else
                    {
                        LogFile.Write("Send Message >>> ShortSend ERROR  Mobile: (" + R.Reciver.Mobile + ")");
                    }
                    ;
                }
                else if (R.Reciver != null && !string.IsNullOrWhiteSpace(R.Reciver.Email))
                {
                    MessagNotification email = new MessagNotification();
                    // set up the email ...
                    email.To = R.Reciver.Email;
                    email.Subject = R.Message.Head;
                    email.ReplyTo = R.Message.Sender.Email;
                    email.Message = R.Message.Body;
                    email.Link = "http://eteelrande";
                    email.FromPerson = R.Message.Sender;
                    try
                    {
                        email.Send();
                        reposetory.MarkSent(R);
                        LogFile.Write("Send Message >>> LongSend  mail: (" + R.Reciver.Email + ")");
                    }
                    catch (Exception e)
                    {
                        LogFile.Write("Send Message Fejl >>> Messagetype " + R.Message.Type.ToString() + " Email: (" + R.Reciver.Email + ") + Mobile: (" + R.Reciver.Mobile + ")");
                    }
                }
                else if (R.Reciver == null)
                {
                    reposetory.MarkSent(R);
                    LogFile.Write("Send Message Fejl >>> Messagetype " + R.Message.Type.ToString() + " Reciever is null");
                }
                else
                {
                    reposetory.MarkSent(R);
                    LogFile.Write("Send Message Fejl >>> Messagetype " + R.Message.Type.ToString() + " Email: (" + R.Reciver.Email + ") + Mobile: (" + R.Reciver.Mobile + ")");
                }

            }


        }