Exemplo n.º 1
0
        public ActionResult Resend(int id)
        {
            try
            {
                var mail = DataContext.Mails.WithSiteId(CurrentSiteId).FirstOrDefault(i => i.Id == id);
                var mailService = new MailService(DataContext);
                var mailSetting = CurrentSite.GetMailSetting();
                if (mailSetting == null)
                {
                    ShowError(MessageResource.ConfigMailSettingFirst);
                }
                else
                {

                    mailService.SendMail(mailSetting, mail);
                    SaveChanges();

                    ShowSuccess(MessageResource.ResendMailSuccess);
                }
            }
            catch
            {
                ShowError(MessageResource.ResendMailFailed);
            }

            return RedirectToIndex();
        }
Exemplo n.º 2
0
	static void Main(string[] args)
	{
		var ctx = new ServiceContext();
		var service = new MailService();
		ctx.LaunchCmdline(typeof(ICmdline), service);
		service.Launch(8090);
		ctx.Run();
	}
Exemplo n.º 3
0
    /// <summary>
    /// Initializes a new instance of the <see cref="OrderConfirmation"/> class.
    /// </summary>
    /// <param name="mailService">The mail service.</param>
    /// <param name="messageBuilder">The message builder.</param>
    public OrderConfirmation([NotNull] MailService mailService, [NotNull] ConfirmationMessageBuilder messageBuilder)
    {
      Assert.ArgumentNotNull(mailService, "mailService");
      Assert.ArgumentNotNull(messageBuilder, "messageBuilder");

      this.mailService = mailService;
      this.messageBuilder = messageBuilder;
    }
Exemplo n.º 4
0
        public InternalsForm(CoreUI ui)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            UI = ui;
            Core = ui.Core;

            Boards = Core.GetService(ServiceIDs.Board) as BoardService;
            Mail = Core.GetService(ServiceIDs.Mail) as MailService;
            Profiles = Core.GetService(ServiceIDs.Profile) as ProfileService;

            Text = "Internals (" + Core.Network.GetLabel() + ")";

            treeStructure.Nodes.Add( new StructureNode("", new ShowDelegate(ShowNone), null));

            // core
                // identity
                // networks (global/operation)
                    // cache
                    // logs
                    // routing
                    // search
                    // store
                    // tcp
                // Components
                    // Link
                    // Location
                    // ...
                // rudp
                    // sessions[]

            // core
            StructureNode coreNode = new StructureNode("Core", new ShowDelegate(ShowCore), null);

            // identity
            coreNode.Nodes.Add( new StructureNode(".Identity", new ShowDelegate(ShowIdentity), null));

            // networks
            if(Core.Context.Lookup != null)
                LoadNetwork(coreNode.Nodes, "Lookup", Core.Context.Lookup.Network);

            LoadNetwork(coreNode.Nodes, "Organization", Core.Network);

            // components
            StructureNode componentsNode = new StructureNode("Components", new ShowDelegate(ShowNone), null);
            LoadComponents(componentsNode);
            coreNode.Nodes.Add(componentsNode);

            treeStructure.Nodes.Add(coreNode);
            coreNode.Expand();
        }
Exemplo n.º 5
0
        public ComposeMail(CoreUI ui, MailService mail, ulong id)
        {
            InitializeComponent();

            UI        = ui;
            Mail      = mail;
            Core      = mail.Core;
            DefaultID = id;

            if (id != 0)
            {
                ToTextBox.Text = Core.GetName(id);
                ToIDs.Add(id);
            }
        }
Exemplo n.º 6
0
        public ComposeMail(CoreUI ui, MailService mail, ulong id)
        {
            InitializeComponent();

            UI = ui;
            Mail = mail;
            Core = mail.Core;
            DefaultID = id;

            if (id != 0)
            {
                ToTextBox.Text = Core.GetName(id);
                ToIDs.Add(id);
            }
        }
        public static void Run()
        {
            var videoEncoder   = new VideoEncoder();   //publisher
            var mailService    = new MailService();    //subscrber
            var messageService = new MessageService(); //another subscriber

            videoEncoder.VideoEncoded += mailService.OnVideoEncoded;
            videoEncoder.VideoEncoded += messageService.OnVideoEncoded;

            var video = new Video {
                Title = "Test video title"
            };

            videoEncoder.Encode(video);
        }
Exemplo n.º 8
0
        public void CompanyInformationIsPresentInEmail()
        {
            MailService testedService = new MailService("localhost");

            testedService.SendMail(new MailAddress("*****@*****.**"),
                                   "Dear customer", "We care!");

            Assert.AreEqual(1, smtpServer.ReceivedEmailCount);

            SmtpMessage sentMail = (SmtpMessage)smtpServer.ReceivedEmail[0];

            Assert.AreEqual("*****@*****.**",
                            sentMail.FromAddress.ToString());
            StringAssert.Contains(sentMail.Data, "Company Support");
        }
Exemplo n.º 9
0
        public void MailSendWithoutToAddressTest()
        {
            var         obj         = _isMptpClient.Object;
            MailMessage mailMessage = new MailMessage();

            _iConfiguration.Setup(c => c.GetSection(It.IsAny <String>())).Returns(new Mock <IConfigurationSection>().Object);
            SendEmailEvent sendEmailEvent = new SendEmailEvent();

            sendEmailEvent.Body    = "test";
            sendEmailEvent.Subject = "test";

            IMailService mailService = new MailService(_isMptpClient.Object, _iConfiguration.Object);

            Assert.Throws <ArgumentNullException>(() => mailService.Execute(sendEmailEvent));
        }
Exemplo n.º 10
0
        private static void TestMailService(System.Collections.Specialized.NameValueCollection appSettings, IBusinessLogic bl, byte[] file)
        {
            var smtpServer = appSettings["smtpServer"];
            var mailAddress = new MailAddress(appSettings["mailAddress"], appSettings["sender"]);
            var user = appSettings["user"];
            var pwd = appSettings["pwd"];
            var port = int.Parse(appSettings["port"]);
            var mailClient = new MailService(smtpServer, port, user, pwd, mailAddress);
            var pdfPath = appSettings["pdfPath"];
            var pdfName = appSettings["pdfName"];

            IEnumerable<Artist> artists = bl.GetArtistsForCategory(new Category() { Id = 1 });
            var days = new List<Spectacleday>(bl.GetSpectacleDays());
            mailClient.MailToArtists(artists, days[0], file);
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            var video = new Video()
            {
                Title = "The Big Lebowsky"
            };
            var videoEncoder   = new VideoEncoder();                 // publisher
            var mailService    = new MailService();                  // subscriber 1
            var messageService = new MessageService();               // subscriber 2

            videoEncoder.VideoEncoded += mailService.OnVideoEncoded; // Add reference to subscriber
            videoEncoder.VideoEncoded += messageService.OnVideoEncoded;

            videoEncoder.Encode(video);
        }
Exemplo n.º 12
0
        public static void Main(string[] args)
        {
            var video = new Video()
            {
                Title = "Video 1"
            };
            var videoEncoder   = new VideoEncoder();   // publisher
            var mailService    = new MailService();    // subscriber
            var messageService = new MessageService(); // subscriber

            videoEncoder.VideoEncoded += mailService.OnVideoEncoded;
            videoEncoder.VideoEncoded += messageService.OnVideoEncoded;

            videoEncoder.Encode(video);
        }
Exemplo n.º 13
0
        static void Main(string[] args)
        {
            var video = new Video()
            {
                Title = "Video 1"
            };
            var videoEncoder   = new VideoEncoder();                 //publisher
            var mailService    = new MailService();                  //subscriber
            var messageService = new MessageService();               //subscriber

            videoEncoder.VideoEncoded += mailService.OnVideoEncoded; //+= to register the handler for that event
            videoEncoder.VideoEncoded += messageService.OnVideoEncoded;

            videoEncoder.Encode(video);
        }
Exemplo n.º 14
0
        public IActionResult Contact(ContactViewModel model)
        {
            if (model.Email.Contains("aol.com"))
            {
                ModelState.AddModelError("Email", "We don't send to AOL.com");
            }

            if (ModelState.IsValid)
            {
                MailService.SendMail(Config["MailSettings:ToAddress"], model.Email, "Test email", model.Message);
                ModelState.Clear();
                ViewBag.UserMessage = "Message Sent";
            }
            return(View());
        }
Exemplo n.º 15
0
 static void Main(string[] args)
 {
     try
     {
         Library.WriteErrorLog(DateTime.Now.ToString() + " : Timer tick started");
         MailService ms  = new MailService();
         MailService ms1 = new MailService();
         Library.WriteErrorLog(DateTime.Now.ToString() + " : Sent Mail");
     }
     catch (Exception ex)
     {
         Library.WriteErrorLog(DateTime.Now.ToString() + " : " + ex.InnerException.ToString());
         throw ex;
     }
 }
Exemplo n.º 16
0
        public ActionResult ExpressOrder(ExpressOrderVM model)
        {
            var isPost = Request.HttpMethod.ToLower() == "post";

            if (isPost)
            {
                MailService.ExpressOrder(model);
                var view = MHtmls.LongList(MHtmls.Title("Экспресс-запрос менеджеру"),
                                           H.p.Class("res_message")["Ваше сообщение отправлено."],
                                           H.p["Наши менеджеры свяжутся с Вами в ближайшее время!"]);
                return(BaseView(
                           new PagePart(view.ToString())));
            }
            return(BaseView(Views.Center.ExpressOrderMobile, new ExpressOrderVM()));
        }
Exemplo n.º 17
0
        public static void UseEvent()
        {
            var video = new Video()
            {
                Title = "Video 1"
            };
            var videoEncoder   = new VideoEncoder();                    //publisher
            var mailService    = new MailService();                     //subscriber
            var messageService = new MessageService();                  //subscriber

            videoEncoder.VideoEncoded += mailService.OnVideoEncoded;    //subscribing
            videoEncoder.VideoEncoded += messageService.OnVideoEncoded; //subscribing

            videoEncoder.Encode(video);
        }
Exemplo n.º 18
0
 public IActionResult PostEmail([FromBody] MailModel mail)
 {
     try
     {
         string mailTo  = mail.Email;
         string subject = $"Contact request from {mail.Name}";
         string body    = $"{mail.Message}, {mail.Phone}";
         MailService.Send(mailTo, subject, body);
         return(Ok());
     }
     catch (Exception ex)
     {
         return(BadRequest(ex));
     }
 }
Exemplo n.º 19
0
        public MailClient(MailBox mailbox, CancellationToken cancelToken, int tcpTimeout = 30000,
                          bool certificatePermit = false, string protocolLogPath = "",
                          ILogger log            = null)
        {
            var protocolLogger = !string.IsNullOrEmpty(protocolLogPath)
                ? (IProtocolLogger)
                                 new ProtocolLogger(protocolLogPath)
                : new NullProtocolLogger();

            Account = mailbox;
            Log     = log ?? new NullLogger();

            StopTokenSource = new CancellationTokenSource();

            CancelToken = CancellationTokenSource.CreateLinkedTokenSource(cancelToken, StopTokenSource.Token).Token;

            if (Account.Imap)
            {
                Imap = new ImapClient(protocolLogger)
                {
                    ServerCertificateValidationCallback = (sender, certificate, chain, errors) =>
                                                          certificatePermit ||
                                                          MailService.DefaultServerCertificateValidationCallback(sender, certificate, chain, errors),
                    Timeout = tcpTimeout
                };

                Pop = null;
            }
            else
            {
                Pop = new Pop3Client(protocolLogger)
                {
                    ServerCertificateValidationCallback = (sender, certificate, chain, errors) =>
                                                          certificatePermit ||
                                                          MailService.DefaultServerCertificateValidationCallback(sender, certificate, chain, errors),
                    Timeout = tcpTimeout
                };
                Imap = null;
            }

            Smtp = new SmtpClient(protocolLogger)
            {
                ServerCertificateValidationCallback = (sender, certificate, chain, errors) =>
                                                      certificatePermit ||
                                                      MailService.DefaultServerCertificateValidationCallback(sender, certificate, chain, errors),
                Timeout = tcpTimeout
            };
        }
Exemplo n.º 20
0
        public JsonResult SendMail(string[] head, string[][] body, string fromAddress, string fromPassword, string[] checkedValue, string selectMonth, string tableName, string emailStyle)
        {
            DataTable     salaryTable = ConvertTable(head, body);
            List <string> allEmail    = new List <string>();
            List <string> correctName = new List <string>();
            List <string> errorName   = new List <string>();
            List <string> allName     = new List <string>();

            for (int i = 0; i < checkedValue.Count(); i++)
            {
                try
                {
                    string name = MailService.GetAllName()[checkedValue[i]];
                    allEmail.Add(name);
                    allName.Add(checkedValue[i]);
                }
                catch (Exception)
                {
                    errorName.Add(checkedValue[i]);
                }
            }

            MailService mailService = new MailService();

            for (int i = 0; i < mailService.AddressName(allEmail).Count; i++)
            {
                try
                {
                    string emailName = MailService.GetAllName()[allName[i]];
                }
                catch (Exception)
                {
                    errorName.Add(checkedValue[i]);
                    continue;
                }
                string chineseName = allName[i];
                try
                {
                    mailService.MailConfiguration(fromAddress, fromPassword, mailService.AddressName(allEmail)[i], chineseName, salaryTable, selectMonth, tableName, emailStyle);
                    correctName.Add(chineseName);
                }
                catch (Exception)
                {
                    errorName.Add(chineseName);
                }
            }
            return(Json(correctName));
        }
Exemplo n.º 21
0
        public ActionResult Create([Bind(Include = "Id,To,Subject,Body")] MailServiceViewModel mailServiceViewModel, HttpPostedFileBase uploadFile)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    MailService mailService = Mapper.Map <MailService>(mailServiceViewModel);
                    mailService.MailSendingDateTime = DateTime.Now;
                    mailService.From = "*****@*****.**";

                    //var result = _mailServiceManager.Add(mailService);
                    //if (result)
                    //{
                    SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
                    smtpClient.Credentials = new NetworkCredential("*****@*****.**", "~Aa123456");
                    smtpClient.EnableSsl   = true;


                    MailMessage mailMessage = new MailMessage();
                    mailMessage.From = new MailAddress("*****@*****.**");
                    mailMessage.To.Add(mailService.To);
                    mailMessage.Subject = mailService.Subject;
                    mailMessage.Body    = mailService.Body;
                    if (uploadFile != null)
                    {
                        string fileName = Path.GetFileName(uploadFile.FileName);

                        mailMessage.Attachments.Add(new Attachment(uploadFile.InputStream, fileName));
                    }
                    smtpClient.Send(mailMessage);

                    TempData["msg"] = "Mail has been save and send successfully";
                    return(RedirectToAction("Index"));

                    //}
                    //ViewBag.RequisitionId = new SelectList(_requisitionManager.GetAllWithEmployee(), "Id", "RequisitionNumber", mailServiceViewModel.RequisitionId);
                    //return View(mailServiceViewModel);
                }

                //ViewBag.RequisitionId = new SelectList(_requisitionManager.GetAllWithEmployee(), "Id", "RequisitionNumber", mailServiceViewModel.RequisitionId);
                return(View(mailServiceViewModel));
            }
            catch (Exception ex)
            {
                ExceptionMessage(ex);
                return(View("Error", new HandleErrorInfo(ex, "MailServices", "Create")));
            }
        }
Exemplo n.º 22
0
        public void BCCandCCTest_ValidCall()
        {
            var mails      = GetSampleUserMails().AsQueryable();
            var users      = GetSamlpeUsers();
            var attachment = new List <Attachment>();

            var mockMailsSet = new Mock <DbSet <UserMail> >();

            mockMailsSet.As <IQueryable <UserMail> >().Setup(m => m.Provider).Returns(mails.Provider);
            mockMailsSet.As <IQueryable <UserMail> >().Setup(m => m.Expression).Returns(mails.Expression);
            mockMailsSet.As <IQueryable <UserMail> >().Setup(m => m.ElementType).Returns(mails.ElementType);
            mockMailsSet.As <IQueryable <UserMail> >().Setup(m => m.GetEnumerator()).Returns(mails.GetEnumerator());

            var mockUsersSet = new Mock <DbSet <User> >();

            mockUsersSet.As <IQueryable <User> >().Setup(m => m.Provider).Returns(users.AsQueryable().Provider);
            mockUsersSet.As <IQueryable <User> >().Setup(m => m.Expression).Returns(users.AsQueryable().Expression);
            mockUsersSet.As <IQueryable <User> >().Setup(m => m.ElementType).Returns(users.AsQueryable().ElementType);
            mockUsersSet.As <IQueryable <User> >().Setup(m => m.GetEnumerator()).Returns(users.GetEnumerator());

            var mockAttachmentsSet = new Mock <DbSet <Attachment> >();

            mockAttachmentsSet.As <IQueryable <Attachment> >().Setup(m => m.Provider).Returns(attachment.AsQueryable().Provider);
            mockAttachmentsSet.As <IQueryable <Attachment> >().Setup(m => m.Expression).Returns(attachment.AsQueryable().Expression);
            mockAttachmentsSet.As <IQueryable <Attachment> >().Setup(m => m.ElementType).Returns(attachment.AsQueryable().ElementType);
            mockAttachmentsSet.As <IQueryable <Attachment> >().Setup(m => m.GetEnumerator()).Returns(attachment.GetEnumerator());

            var mockContext = new Mock <MailBoxDBContext>();

            mockContext.Setup(c => c.UserMails).Returns(mockMailsSet.Object);
            mockContext.Setup(c => c.Users).Returns(mockUsersSet.Object);
            mockContext.Setup(c => c.Attachments).Returns(mockAttachmentsSet.Object);

            var mockNotificationService = new Mock <NotificationService>();

            var mockConfiguration = new Mock <IConfiguration>();

            var service = new MailService(mockConfiguration.Object, mockContext.Object, mockNotificationService.Object);

            var user10Mais = service.GetMail(10, 3);
            var user11Mais = service.GetMail(11, 3);

            Assert.Equal(2, user10Mais.RecipientsAddresses.Count);
            Assert.Single(user11Mais.RecipientsAddresses);
            Assert.Equal("*****@*****.**", user11Mais.RecipientsAddresses[0]);
            Assert.Equal("*****@*****.**", user10Mais.RecipientsAddresses[0]);
            Assert.Equal("*****@*****.**", user10Mais.RecipientsAddresses[1]);
        }
        public async Task <IActionResult> CreateTransferFlow([FromBody] SaveTransferFlowResource saveTransferResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            else if (await _repository.CheckOrder(saveTransferResource.MasterId, saveTransferResource.SequenceNumber))
            {
                return(BadRequest("Siz emeliyyati artiq yerine yetirmisiniz!"));
            }

            var flowMaster = _mapper.Map <SaveTransferFlowResource, OsStFlowmaster>(saveTransferResource);

            flowMaster.CreatedDate = DateTime.Now;
            flowMaster.StatusId    = 5;//In Progress

            var item = await _repository.UpdateItemForFlow(saveTransferResource.ItemCode, saveTransferResource.CompanyId);

            if (item == null)
            {
                return(BadRequest());
            }
            flowMaster.CategoryId    = item.CategoryId;
            flowMaster.SubCategoryId = item.SubCategoryId;

            _repository.AddMaster(flowMaster);
            await _unitOfWork.CompleteAsync();

            var flowLine = _mapper.Map <SaveTransferFlowResource, OsStFlowlines>(saveTransferResource);

            flowLine.MasterId     = flowMaster.Id;
            flowLine.ExecutedDate = DateTime.Now;

            _repository.AddLine(flowLine);
            await _unitOfWork.CompleteAsync();


            if (saveTransferResource.FlowTypeId == 2 && saveTransferResource.SequenceNumber == 1)// b.m transfer kecenden sonra t.m mail getmesi
            {
                MailService.MailSender(_appSettings.CommercialMarketingMail, "https://onsale.veyseloglu.az:4443/transfer/" + flowLine.MasterId, flowLine.MasterId.ToString());
            }
            else if (saveTransferResource.FlowTypeId == 3 && saveTransferResource.SequenceNumber == 1)//b.m qaytarma kecibse t mail getmesi
            {
                MailService.MailSender(_appSettings.OutfitMail, "https://onsale.veyseloglu.az:4443/transfer/" + flowLine.MasterId, flowLine.MasterId.ToString());
            }

            return(Ok(saveTransferResource));
        }
Exemplo n.º 24
0
        public async Task <ServiceResult <Authentication> > MailExists(string mail)
        {
            var valid = await MailService.IsValidMailAddress(mail);

            if (!valid.ExtraData)
            {
                return(Invalid <Authentication>(null, "邮箱格式错误"));
            }
            var auth = await Context.Authentications.FirstOrDefaultAsync(at => at.Type == Authentication.AuthTypeEnum.MailAddress && at.AuthToken == mail);

            if (auth == null)
            {
                return(NotFound <Authentication>(null, "邮箱未注册"));
            }
            return(Exist(auth, "邮箱已注册"));
        }
Exemplo n.º 25
0
        // GET: MailServices/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MailService mailService = _mailServiceManager.FindById((int)id);

            if (mailService == null)
            {
                return(HttpNotFound());
            }
            MailServiceViewModel mailServiceViewModel = Mapper.Map <MailServiceViewModel>(mailService);

            return(View(mailServiceViewModel));
        }
Exemplo n.º 26
0
            public ActionResult Contact(ContactModel model)
            {
            var msg = string.Format("Comment Form: {1}{0}Email:{2}{0}Website: {3}{0}Comments" Environment.NewLine,
                model.Name,
                model.Email,
                model.Website,
                model.Comment);

            var svc = new MailService();

            if (_mail.SendMail("*****@*****.**", "*****@*****.**", "Website Contact", msg))
            {
                ViewBag.MailSent = true;
            }
            return View();
            }
Exemplo n.º 27
0
            public void SendsAnEmailWithTheProperSubject(
                NonEmptyString nonEmptyString)
            {
                var subject = nonEmptyString.Get;

                PlatformConstants.FeedbackEmailSubject.Returns(subject);

                ViewModel.SubmitFeedback().Wait();

                MailService.Received()
                .Send(
                    Arg.Any <string>(),
                    subject,
                    Arg.Any <string>())
                .Wait();
            }
Exemplo n.º 28
0
        static void Main(string[] args)
        {
            var vedio = new Vedio {
                Title = "Vedio 1"
            };
            //publisher
            var vedioEncoder = new VedioEncoder();
            //subscriber
            var mailService    = new MailService();
            var messageService = new MessageService();

            vedioEncoder.VedioEncoded += mailService.OnVedioEncoded;
            vedioEncoder.VedioEncoded += messageService.OnVedioEncoded;

            vedioEncoder.Encode(vedio);
        }
Exemplo n.º 29
0
 public ExpertService(IUserRepository userRepository,
                      IExpertApplicationRepository expertApplicationRepository,
                      IClock clock,
                      ICountryRepository countryRepository,
                      ExpertApplicationsStorageProvider expertApplicationsStorageProvider,
                      IExpertRepository expertRepository,
                      MailService mailService)
 {
     _userRepository                    = userRepository;
     _expertRepository                  = expertRepository;
     _countryRepository                 = countryRepository;
     _mailService                       = mailService;
     _expertApplicationRepository       = expertApplicationRepository;
     _expertApplicationsStorageProvider = expertApplicationsStorageProvider;
     _clock = clock;
 }
Exemplo n.º 30
0
        public void MessageBodyIsBuildByMessageBuilderReturnedFromFactory()
        {
            MailMessageType mailMessageType = It.IsAny <MailMessageType>();
            var             mailContext     = new MailContext()
            {
                EmailContent = new MailContent(mailMessageType)
            };
            IMessageBuilder messageBuilder = Mock.Of <IMessageBuilder>(builder => builder.BuildMessageContent(mailContext) == "test message");
            MailService     mailService    = new MailService(Mock.Of <IClient>(),
                                                             Mock.Of <IMessageBuilderFactory>(factory => factory.CreateMessageBuilder(mailMessageType) == messageBuilder));

            MailContext context = mailService.BuildMessage(mailContext);

            Mock.Get(messageBuilder).Verify(x => x.BuildMessageContent(mailContext), Times.Once);
            context.EmailContent.MessageBody.Should().Be("test message");
        }
Exemplo n.º 31
0
        static void Main(string[] args)
        {
            Computation computation = new Computation()
            {
                Title = "Print File"
            };
            DoComputation doComputation = new DoComputation();

            MailService    mailService    = new MailService();
            MessageService messageService = new MessageService();

            doComputation.Computed += mailService.OnComputed;
            doComputation.Computed += messageService.OnComputed;

            doComputation.Compute(computation);
        }
Exemplo n.º 32
0
        public void SendMail()
        {
            MailService mailService = new MailService();

            mailService.SendMail("*****@*****.**", "*****@*****.**", "this is a test", "test mail GolfLabel.net");

            for (int i = 0; i < 10; i++)
            {
                if (mailService.MailWasSend)
                {
                    return;
                }
                System.Threading.Thread.Sleep(500);
            }
            Assert.IsTrue(mailService.MailWasSend);
        }
Exemplo n.º 33
0
        public async Task ShouldSendMail()
        {
            var smtpClientMock = new Mock <ISmtpClient>();

            smtpClientMock.Setup(x => x.SendMailAsync(It.IsAny <MailMessage>())).Returns(Task.CompletedTask);
            var interpolationService = new StringInterpolationService(new ReflectionService());

            var mailOptionsMock = new OptionsMock <FsMail>(new FsMail {
                FromAddress = "*****@*****.**", Host = "123", Port = 123
            });
            var mailService = new MailService(mailOptionsMock, interpolationService, smtpClientMock.Object);

            var message = new MailMessage <TestModel>("*****@*****.**", "test subject", "test body {Test}", new TestModel());

            await mailService.SendMail(message);
        }
Exemplo n.º 34
0
        public static void Main(string[] args)
        {
            var video = new Video {
                Title = "video 1"
            };
            var videoEncoder = new VideoEncoder();   // publisher
            var mailService  = new MailService();    // subscriber
            var msgService   = new MessageService(); //subscriber II

            //below the mail service is subscribing to the event VideoEncoded (or the event publisher Video Encoder)
            videoEncoder.VideoEncoded += mailService.OnVideoEncoded;
            videoEncoder.VideoEncoded += msgService.OnVideoEncoded;


            videoEncoder.Encode(video);
        }
Exemplo n.º 35
0
        static void Main(string[] args)
        {
            var video = new Video()
            {
                Title = "Video"
            };
            var videoEncoder   = new VideoEncoder();
            var mailService    = new MailService();
            var messageService = new MessageService();


            videoEncoder.VideoEncoded += mailService.OnVideoEncoded;
            videoEncoder.VideoEncoded += messageService.OnVideoEncoded;

            videoEncoder.Encode(video);
        }
Exemplo n.º 36
0
 public Setting(Models.Campaign currentCampagne, string to, string obj, string msg, bool allCampagne)
 {
     //On récupère les valeurs transmises en paramètre
     this.currentCampagne = currentCampagne;
     this.to          = to;
     this.obj         = obj;
     this.msg         = msg;
     this.allCampagne = allCampagne;
     //Définition du context
     this.context = new Context();
     //On initialise les services
     this.contactService = new ContactService(this.context);
     this.mailService    = new MailService(this.context);
     //On initialise les composants à afficher
     InitializeComponent();
 }
Exemplo n.º 37
0
            public async Task WhenSendEmailGetsCalled()
            {
                Setup();

                _expectedMailMessage = new MailMessage(new MailAddress("*****@*****.**", "SMP"), new MailAddress(ReceiverEmail))
                {
                    Subject    = EmailSubject,
                    Body       = EmailBody,
                    IsBodyHtml = true
                };

                SmtpClient.Setup(client => client.SendMailAsync(It.IsAny <MailMessage>()))
                .Callback <MailMessage>(message => _usedMailMessage = message);

                await MailService.SendEmail(ReceiverEmail, EmailSubject, EmailBody);
            }
Exemplo n.º 38
0
    /// <summary>
    /// 發確認信給會員
    /// </summary>
    /// <param name="messageVO"></param>
    public void SendConfirmMail_ToMember(MemberVO memberVO)
    {
        try
        {
            SystemParamVO mailVO = m_SystemService.GetSystemParamByRoot();
            MailService mailService = new MailService(mailVO.MailSmtp, int.Parse(mailVO.MailPort), mailVO.EnableSSL, mailVO.Account, mailVO.Password);

            string mailTitle = "收到一封從網站的會員認證信。";
            string mailContent = GenMailContent(memberVO);

            mailService.SendMail(mailVO.SendEmail, memberVO.Email, mailTitle, mailContent);
        }
        catch (Exception ex)
        {
            m_Log.Error(ex);
        }
    }
Exemplo n.º 39
0
        public MailView(MailUI ui)
        {
            InitializeComponent();

            UI = ui;
            Mail = ui.Mail;
            Core  = ui.Core;
            Trust = Core.Trust;

            MessageView.SmallImageList = new List<Image>();
            MessageView.SmallImageList.Add(MailRes.recvmail);
            MessageView.SmallImageList.Add(MailRes.sentmail);

            MessageHeader.DocumentText = HeaderPage.ToString();

            GuiUtils.SetupToolstrip(toolStrip1, new OpusColorTable());

            MessageBody.Core = Core;
        }
Exemplo n.º 40
0
        public WuDADAMailService()
        {
            IApplicationContext ctx = ContextRegistry.GetContext();
            myService = (MyService)ctx.GetObject("MyService");
            authService = (IAuthService)ctx.GetObject("AuthService");

            systemParamVO = myService.Dao.DaoGetVOById<SystemParamVO>(VarHelper.WuDADA_SYSTEMPARAM_ID);

            bool enableSSL = systemParamVO.IsEnableSSL;
            int port = 25;

            if (systemParamVO.MailSmtp.IndexOf("gmail") != -1)
            {
                enableSSL = true;
                port = 587;
            }
            else if (!string.IsNullOrEmpty(systemParamVO.MailPort))
            {
                port = int.Parse(systemParamVO.MailPort);
            }
            mailService = new MailService(systemParamVO.MailSmtp, port, enableSSL, systemParamVO.Account, systemParamVO.Password);
        }
Exemplo n.º 41
0
    public WebMailService()
    {
        m_ConfigHelper = new ConfigHelper();
        m_SystemFactory = new SystemFactory();
        m_SystemService = m_SystemFactory.GetSystemService();

        m_MailVO = m_SystemService.GetSystemParamByRoot();

        bool enableSSL = m_MailVO.EnableSSL;
        int port = 25;

        if (m_MailVO.MailSmtp.IndexOf("gmail") != -1)
        {
            enableSSL = true;
            port = 587;
        }
        else if (!string.IsNullOrEmpty(m_MailVO.MailPort))
        {
            port = int.Parse(m_MailVO.MailPort);
        }

        m_MailService = new MailService(m_MailVO.MailSmtp, port, enableSSL, m_MailVO.Account, m_MailVO.Password);
    }
Exemplo n.º 42
0
    /// <summary>
    /// 發信給設定的信箱 By 訊息
    /// </summary>
    /// <param name="messageVO"></param>
    public void SendMail_ToContactor_ByMessage(MessageVO messageVO)
    {
        try
        {
            string classify = "聯絡我們收件者";
            IList<ItemParamVO> contactorList = m_SystemService.GetAllItemParamByNoDel(classify);

            if (contactorList != null && contactorList.Count > 0)
            {
                SystemParamVO mailVO = m_SystemService.GetSystemParamByRoot();
                MailService mailService = new MailService(mailVO.MailSmtp, int.Parse(mailVO.MailPort), mailVO.EnableSSL, mailVO.Account, mailVO.Password);

                StringBuilder sbMailList = new StringBuilder();
                foreach (ItemParamVO contactor in contactorList)
                {
                    sbMailList.Append(string.Format("{0};", contactor.Value));
                }

                string mailTitle = string.Format("收到一封由【{0}】從網站發出的線上諮詢。", messageVO.CreateName);
                string mailContent = GenMailContent(messageVO);

                mailService.SendMail(mailVO.SendEmail, sbMailList.ToString(), mailTitle, mailContent);
            }
        }
        catch (Exception ex)
        {
            m_Log.Error(ex);
        }
    }
Exemplo n.º 43
0
        void mailService_VoiceMail_GetMessageCompleted(object sender, MailService.VoiceMail_GetMessageCompletedEventArgs e)
        {
            if (e.Cancelled || e.Error != null || e.Result == null)
                return;

            this.Invoke(new DownloadCompleted(MailDownloadCompleted), new Object[] { e.Result });
        }
Exemplo n.º 44
0
        private bool mailSend(List<WordDic> shinseiWordDicList, int shinseiKbn)
        {
            string messageBody = "単語の承認・却下が完了しました。" + System.Environment.NewLine + System.Environment.NewLine;
            string messageSubject = "承認・却下完了";
            foreach (WordDic obj in shinseiWordDicList)
            {
                messageBody += ((ShinseiKbn)shinseiKbn).ToString() +  "・・・  論理名1:" + obj.ronri_name1 + "、論理名2:" + obj.ronri_name2 + "、物理名:" + obj.butsuri_name + " " + System.Environment.NewLine;
            }

            MailService mailService = new MailService();
            MailServiceInBo inBo = new MailServiceInBo();
            inBo.messageSubject = messageSubject;
            inBo.messageBody = messageBody;
            mailService.setInBo(inBo);
            MailServiceOutBo outBo = mailService.execute();

            if (!string.IsNullOrEmpty(outBo.errorMessage))
            {
                MessageBox.Show(outBo.errorMessage);
                return false;
            }

            MessageBox.Show(MessageConst.CONF_008);
            return true;
        }
Exemplo n.º 45
0
        void mailSerive_VoiceMail_GetMessageListCompleted(object sender, MailService.VoiceMail_GetMessageListCompletedEventArgs e)
        {
            mPerformingUpdate = false;

            if (e.Cancelled || e.Error != null || e.Result == null)
                return;

            this.Invoke(new MessageListUpdated(MessageListUpdate), new Object[] { e.Result });
        }
Exemplo n.º 46
0
        void MessageListUpdate(MailService.FileInfo[] list)
        {
            int newInboxFiles = 0;
            int newArchiveFiles = 0;

            foreach (MailService.FileInfo info in list)
            {
                try
                {
                    //File was not in our local list, so add it
                    if (pEmailEntries.Controls.ContainsKey(info.FileName) == false)
                    {
                        if (info.Location == MailService.LocationType.INBOX)
                            ++newInboxFiles;
                        else if (info.Location == MailService.LocationType.ARCHIVE)
                            ++newArchiveFiles;

                        String newFileInfoName = this.BasePath + info.Location.ToString() + @"\" + info.FileName + ".xml"; ;
                        String tempFileInfoName = Path.GetTempFileName();

                        XmlSerializer ser = new XmlSerializer(typeof(InfoFile));
                        FileStream fs = File.OpenWrite(tempFileInfoName);

                        InfoFile infoFile = new InfoFile(info);
                        infoFile.Cached = File.Exists(mBaseDirectory + info.Location.ToString() + @"\" + info.FileName);

                        ser.Serialize(fs, infoFile);
                        fs.Close();

                        //Now move files
                        if (File.Exists(newFileInfoName)) File.Delete(newFileInfoName);
                        File.Move(tempFileInfoName, newFileInfoName);

                        pEmailEntries.Controls.Add(new VoiceMailEntry(this, infoFile));

                    }
                    else
                    {
                        //Check for a message which may have moved from Inbox to Archive
                        VoiceMailEntry entry = (VoiceMailEntry)pEmailEntries.Controls[info.FileName];
                        if ((MailService.LocationType)entry.Info.Location != info.Location && info.Location == MailService.LocationType.ARCHIVE)
                            entry.ArchiveLocal();
                    }
                }
                catch
                {
                }
            }

            if (newInboxFiles > 0 || newArchiveFiles > 0)
                OnNewMailEvent(this, newInboxFiles, newArchiveFiles);
        }
Exemplo n.º 47
0
        void MailDownloadCompleted(MailService.MessageReturn message)
        {
            if (message.Error == MailService.ReturnStatus.Success)
            {
                if (message.CompressedFormat == MailService.CompressionType.None)
                {
                    try
                    {
                        String newFileName = mOwner.BasePath + mFileInfo.Location.ToString() + @"\" + mFileInfo.FileName;
                        String newFileInfoName = newFileName + ".xml";
                        String tempFileName = Path.GetTempFileName();
                        String tempFileInfoName = Path.GetTempFileName();

                        File.WriteAllBytes(tempFileName, message.Bytes);

                        XmlSerializer ser = new XmlSerializer(typeof(InfoFile));
                        FileStream fs = File.OpenWrite(tempFileInfoName);
                        ser.Serialize(fs, mFileInfo);
                        fs.Close();

                        //Now move files
                        if (File.Exists(newFileName)) File.Delete(newFileName);
                        File.Move(tempFileName, newFileName);
                        if (File.Exists(newFileInfoName)) File.Delete(newFileInfoName);
                        File.Move(tempFileInfoName, newFileInfoName);

                        mCached = true;
                        ResetButtonDesign();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("MailDownloadCompleted :" + ex.Message);
                        //todo, maybe inform user??
                    }
                }
            }
            //Remove the service from ourself
            mDownloadService.VoiceMail_GetMessageCompleted -= new MailService.VoiceMail_GetMessageCompletedEventHandler(mailService_VoiceMail_GetMessageCompleted);
            mDownloadService = null;
            this.progressBar.Enabled = false;
            this.progressBar.Visible = false;
            mDownloadInProgress = false;
            if (Selected) { 
                mOwner.SetFileDownloadInProgress = false;
                SelectControl();
            }
            
        }
Exemplo n.º 48
0
        public ActionResult SubmitAndEmailUser(LoginUser loguser)
        {
            if (loguser.LoginRole != null && !string.IsNullOrWhiteSpace(loguser.Email))
            {
                if (loguser.LoginRole != null)
                {
                    if (loguser.LoginRole.Roles != RolesString.AWAM)
                    {
                        loguser.Email = "NA";
                        loguser.AlternativeEmail = "NA";
                        if (loguser.UserId == 0)
                            loguser.Salt = Guid.NewGuid().ToString();
                    }
                }
                if (loguser.UserId == 0)
                {
                    loguser.CreatedDt = DateTime.Now;
                    loguser.CreatedBy = User.Identity.Name;
                }
                loguser.IsLocked = loguser.Status != "Aktif";
                loguser.FirstTime = true;
                if (loguser.Save() > 0)
                {
                    // change the password if the is new password
                    if (loguser.UserId != 0)
                        loguser.ChangePassword(loguser.Password);

                    var user = ObjectBuilder.GetObject<ILoginUserPersistance>("LoginUserPersistance").GetByUserName(User.Identity.Name);
                    if (null != user)
                    {
                        var url = this.Request.Url;
                        if (url != null)
                        {
                            var from = ConfigurationManager.AppSettings["fromEmail"];
                            var loginurl = ConfigurationManager.AppSettings["server"] + "/Account/Login";
                            var templatepath = Path.Combine(System.Web.HttpContext.Current.Server.MapPath(@"~/Templates"), "TempPassword.html");
                            var mail = new MailService();
                            mail.SendMail("[JOM MASUK TENTERA]Notifikasi Kata Laluan Sementara", from, new List<string> { loguser.Email, loguser.AlternativeEmail }, null, null, loguser, loginurl, templatepath, DateTime.Now);
                        }
                        ObjectBuilder.GetObject<ILoginUserPersistance>("LoginUserPersistance").LoggingUser(user.UserId, LogStatusCodeString.Create_User, User.Identity.Name, DateTime.Now);
                    }
                    return Json(new { OK = true, message = "Berjaya." });
                }
            }
            return Json(new { OK = false, message = "Tidak Berjaya." });
        }
Exemplo n.º 49
-1
        public static void Main(string[] args)
        {
            var video = new Video() { Title = "Video 1"};
            var videoEncoder = new VideoEncoder(); //publisher
            var mailService = new MailService(); //subscriber
            var messageService = new MessageService();

            videoEncoder.VideoEncoded += mailService.OnVideoEncoded;
            videoEncoder.VideoEncoded += messageService.OnVideoEncoded;

            videoEncoder.Encode(video);
        }
Exemplo n.º 50
-1
        static void Main(string[] args)
        {
            Video myVideo = new Video();
            myVideo.Title = "Video 1";

            VideoEncoder myVideoEncoder = new VideoEncoder();       // Publisher
            MailService myMailService = new MailService();          // Subscriber
            MessageService myMessageService = new MessageService(); // Another subscriber

            myVideoEncoder.VideoEncoded += myMessageService.OnVideoEncoded;
            myVideoEncoder.VideoEncoded += myMailService.OnVideoEncoded; /* Code explanation:
                                                                         * the object "myVideoEncoder" has an event called "VideoEncoded",
                                                                         * we then add the "OnVideoEncoded" method from "myMailService" as a subscriber,
                                                                         * so that when "myVideoEncoder" raises the event "VideoEncoded", the
                                                                         * function: "OnVideoEncoded" is called from the class: "myMailService".
                                                                         */

            myVideoEncoder.Encode(myVideo);
        }