Ejemplo n.º 1
0
        public async Task SendEmailEmptyPasswordTaskSpanishKo()
        {
            var defaultCulture = Thread.CurrentThread.CurrentUICulture;

            Thread.CurrentThread.CurrentUICulture = new CultureInfo("es-ES");

            var smtp = GetService <IOptionsService <SmtpSettings> >();

            smtp.Value.Password = null;
            var sender = new SmtpEmailSender(smtp);

            var bytes = await GetPhotoBinary();

            var attachment = new EmailAttachment("Adjunto", bytes);

            Task Action()
            {
                return(sender.SendEmailAsync("*****@*****.**", "Testing con adjunto",
                                             "Prueba testing con adjunto", attachment));
            }

            var exception = await Assert.ThrowsAsync <EmailException>(Action);

            //The thrown exception can be used for even more detailed assertions.
            Assert.Equal(ExceptionCodes.SMT_PASS_EMPTY, exception.Message);

            Thread.CurrentThread.CurrentUICulture = defaultCulture;
        }
Ejemplo n.º 2
0
        public void Main(string[] args)
        {
            var mail = new SmtpEmailSender("smtp.ym.163.com", 25, "Code Comb", "*****@*****.**", "*****@*****.**", "123456");

            mail.SendEmailAsync("*****@*****.**", "关于MailSender项目说明", "<html><head><meta http-equiv=\"Content-type\" content=\"text/html;charset=utf-8\"/></head><body>能收到邮件吗</body></html>").Wait();
            Console.Read();
        }
Ejemplo n.º 3
0
        public async Task SendEmailOk()
        {
            var sender = new SmtpEmailSender(GetService <IOptionsService <SmtpSettings> >());

            await sender.SendEmailAsync("Testing", "Prueba testing");

            Assert.True(true);
        }
Ejemplo n.º 4
0
        public async Task SendEmailWithAttachmentOk()
        {
            var sender = new SmtpEmailSender(GetService <IOptionsService <SmtpSettings> >());

            var bytes = await GetPhotoBinary();

            var attachment = new EmailAttachment("Adjunto.jpg", bytes);

            await sender.SendEmailAsync("Testing con adjunto",
                                        "Prueba testing con adjunto", attachment);

            Assert.True(true);
        }
Ejemplo n.º 5
0
        public void SendSimpleMail()
        {
            IEmailSender emailSender = new SmtpEmailSender(() => {
                SmtpSettings settings      = new SmtpSettings();
                settings.SmtpMailServer    = "smtp.gmail.com";
                settings.SmtpPort          = 465;
                settings.SenderLogin       = "******";
                settings.SenderDisplayName = "dmi yermachenko";
                settings.SenderPassword    = "******";
                settings.SenderEmail       = "*****@*****.**";
                return(settings);
            }, null);

            emailSender.SendEmailAsync("*****@*****.**", "Your test was succees", "Reporting entry").Wait();
        }
Ejemplo n.º 6
0
        public async Task SendEmailWithAttachmentNotFilenameExtensionKo()
        {
            var sender = new SmtpEmailSender(GetService <IOptionsService <SmtpSettings> >());

            var bytes = await GetPhotoBinary();

            var attachment = new EmailAttachment("Adjunto", bytes);

            Task Action()
            {
                return(sender.SendEmailAsync("*****@*****.**", "Testing con adjunto",
                                             "Prueba testing con adjunto", attachment));
            }

            var exception = await Assert.ThrowsAsync <EmailException>(Action);

            //The thrown exception can be used for even more detailed assertions.
            Assert.Equal(ExceptionCodes.EMAIL_ATTACH_EXT, exception.Message);
        }
Ejemplo n.º 7
0
 public void Main(string[] args)
 {
     var mail = new SmtpEmailSender("smtp.ym.163.com", 25, "Code Comb", "*****@*****.**", "*****@*****.**", "123456");
     mail.SendEmailAsync("*****@*****.**","关于MailSender项目说明", "<html><head><meta http-equiv=\"Content-type\" content=\"text/html;charset=utf-8\"/></head><body>能收到邮件吗</body></html>").Wait();
     Console.Read();
 }
Ejemplo n.º 8
0
        public static async Task ActualizarSolicitud(IDialogContext context, string estado)
        {
            try
            {
                var container = new Container();
                UnityConfig.RegisterTypes(container);

                var       solicitudManager = container.GetInstance <ISolicitud>();
                Solicitud solicitud        = context.UserData.GetValueOrDefault <Solicitud>("solicitud");
                Sesion    sesion           = context.UserData.GetValue <Sesion>("sesion");
                string    curso            = context.UserData.GetValue <string>("Curso");
                string    userName         = sesion.CodigoAlumno;

                Result receivedResult;
                context.UserData.TryGetValue("result", out receivedResult);

                Intencion intent;
                context.UserData.TryGetValue("intencion", out intent);

                ActivitiesByCourseViewModel actividad;
                context.UserData.TryGetValue("Actividad", out actividad);

                if (solicitud != null)
                {
                    long?intentId = null;

                    if (intent != null)
                    {
                        intentId = intent.IdIntencion;
                    }

                    var cursoManager = container.GetInstance <ICurso>();

                    List <CourseByModuleViewModel> studentActiveCourses = cursoManager.GetCourseByModuleActive(solicitud.IdAlumno);

                    CourseByModuleViewModel docenteCurso = studentActiveCourses.Where(s => s.Curso == curso).FirstOrDefault();

                    var respuestaPersonalizada = context.PrivateConversationData.GetValueOrDefault("custom", string.Empty);
                    var solucion = respuestaPersonalizada.Equals(string.Empty) ? receivedResult?.Speech : respuestaPersonalizada;

                    //await context.PostAsync(solucion);

                    int?idActividad  = actividad?.IdActividad;
                    int?idEmpleado   = docenteCurso?.IdEmpleado;
                    int?cumpleSLA    = 2;
                    var tipoConsulta = context.UserData.GetValue <string>("tipo-consulta");

                    var dif = ConvertidorUtil.GmtToPacific(DateTime.Now).Subtract(solicitud.FechaRegistro).TotalHours;

                    if (tipoConsulta == "1" && dif <= 48)
                    {
                        cumpleSLA = 1;
                    }
                    else
                    {
                        if (dif <= 24)
                        {
                            cumpleSLA = 1;
                        }
                    }


                    bool IsEmailSent = false;

                    DateTime?fechaSolucion = null;

                    switch (estado)
                    {
                    case "A":
                        fechaSolucion = ConvertidorUtil.GmtToPacific(DateTime.Now);
                        break;

                    case "D":

                        solucion  = string.Empty;
                        cumpleSLA = 0;

                        if (!string.IsNullOrEmpty(docenteCurso?.Email))
                        {
                            IsEmailSent = await SmtpEmailSender.SendEmailAsync("*****@*****.**",
                                                                               docenteCurso.Email,
                                                                               "UPECITO - Consultas Académicas No Resueltas",
                                                                               EmailTeacher(sesion.CodigoAlumno, sesion.NombreApePaterno, solicitud.Consulta));
                        }

                        if (IsEmailSent)
                        {
                            await context.PostAsync($"Su consulta ha sido derivada al Docente: {docenteCurso.Nombre} {docenteCurso.ApellidoPat}; quien le brindará una respuesta");
                        }
                        else
                        {
                            await context.PostAsync(receivedResult.Speech);
                        }

                        break;

                    default:
                        solucion  = string.Empty;
                        cumpleSLA = 0;

                        break;
                    }

                    solicitudManager.Actualizar(solicitud.IdSolicitud, intentId, solucion, estado, userName, docenteCurso?.IdCurso, idActividad, idEmpleado, cumpleSLA, fechaSolucion);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }