Esempio n. 1
0
        public static string SendEmail50(IEnumerable <AspNetUser> users, string subject, string body, bool BCCOnly, bool isHTML, string path)
        {
            try
            {
                DB_A0B2A3_conferenceEntities context = new DB_A0B2A3_conferenceEntities();
                var emailinfo = context.SysSettings.Where(x => x.Item == "EmailInfo").FirstOrDefault();

                MailMessage m  = new MailMessage();
                SmtpClient  sc = new SmtpClient(emailinfo.Value1);


                if (users.Count() == 0)
                {
                    return("Fail: No Users");
                }


                m.From = new MailAddress(emailinfo.Value2);


                foreach (var user in users.Distinct())
                {
                    if (BCCOnly)
                    {
                        m.Bcc.Add(user.Email);
                    }
                    else
                    {
                        m.To.Add(user.Email);
                    }
                }


                m.Subject = subject;


                m.Body = body;

                //if (path != "") m.Attachments.Add(new Attachment(path));


                if (path != "")
                {
                    m.Body = body + "<br><a href='http://www.ptpdms.com/Temp/" + path + "'>Click here for attachment</a>";
                }

                sc.Port        = int.Parse(emailinfo.Value5);
                sc.Credentials = new System.Net.NetworkCredential(emailinfo.Value3, emailinfo.Value4);
                // sc.EnableSsl = true;

                m.IsBodyHtml = isHTML;

                sc.Send(m);
                return("Success");
            }
            catch (Exception ex)
            {
                return("Error:" + ex.Message);
            }
        }
Esempio n. 2
0
 public static string GetUserType()
 {
     if (HttpContext.Current.User.Identity.IsAuthenticated)
     {
         string userid = HttpContext.Current.User.Identity.GetUserId();
         DB_A0B2A3_conferenceEntities context = new DB_A0B2A3_conferenceEntities();
         var s = context.AspNetUsers.Find(userid);
         return(s.SysUserType.TypeName);
     }
     return("error");
 }
Esempio n. 3
0
        public static string SendEmail(string emailaddress, string subject, string body, bool ishtml, string path)
        {
            try
            {
                DB_A0B2A3_conferenceEntities context = new DB_A0B2A3_conferenceEntities();
                var emailinfo = context.SysSettings.Where(x => x.Item == "EmailInfo").FirstOrDefault();

                MailMessage m  = new MailMessage();
                SmtpClient  sc = new SmtpClient(emailinfo.Value1);


                m.From = new MailAddress(emailinfo.Value2);
                m.To.Add(emailaddress);

                m.Subject = subject;

                m.Body = body;



                // if (path != "") m.Attachments.Add(new Attachment(path));

                if (path != "")
                {
                    m.Body = body + "<br><a href='http://www.ptpdms.com/Temp/" + path + "'>Click here for attachment</a>";
                }

                sc.Port        = int.Parse(emailinfo.Value5);
                sc.Credentials = new System.Net.NetworkCredential(emailinfo.Value3, emailinfo.Value4);
                // sc.EnableSsl = true;

                m.IsBodyHtml = ishtml;

                sc.Send(m);
                return("Success");
            }
            catch (Exception ex)
            {
                return("Error:" + ex.Message);
            }
        }
Esempio n. 4
0
        public static bool UploadPowerPoint(HttpPostedFileBase upload, int abstractid)
        {
            Random rand = new Random();
            DB_A0B2A3_conferenceEntities context = new DB_A0B2A3_conferenceEntities();

            var importfile = new SysFilePath
            {
                FileName   = "PPFile_" + rand.Next(1000, 9999).ToString() + "_" + System.IO.Path.GetFileName(upload.FileName),
                LinkId     = abstractid,
                FileType   = "PowerPoint File",
                UploadDate = DateTime.Now
            };

            context.SysFilePaths.Add(importfile);
            context.SaveChanges();

            string namefromdb = "~/Temp/" + importfile.FileName;

            string path = HttpContext.Current.Server.MapPath(namefromdb);

            upload.SaveAs(path);

            return(true);
        }