コード例 #1
0
 public ComposeEmail(UserAccount ua, string recipient)
 {
     InitializeComponent();
     _userAccount    = ua;
     _mailEngine     = new MailEngine();
     _sendToTxt.Text = recipient;
 }
コード例 #2
0
 public ComposeEmail(UserAccount ua, string recipient, string originalContent)
 {
     InitializeComponent();
     _userAccount     = ua;
     _mailEngine      = new MailEngine();
     _sendToTxt.Text  = recipient;
     _isReply         = true;
     _originalContent = originalContent;
 }
コード例 #3
0
        protected int StartMailEngine(BackgroundWorker worker)
        {
            _mailEngineReceive = new MailEngine(_userAccount, worker, _isAddAccount);

            if (!_mailEngineReceive.EngineStarted)
            {
                return(1);
            }

            _emailContent = _mailEngineReceive.EmailContent;
            return(0);
        }
コード例 #4
0
ファイル: HomeController.cs プロジェクト: bilginesme/des-tech
        public PartialViewResult _ParContactFormSave(FormCollection values)
        {
            string strCaptcha = HttpContext.Session["captchastring"].ToString();

            if (strCaptcha == values["txtCaptcha"])
            {
                string strBody = "Message from : " + values["txtName"] + " [" + values["txtEmail"] + "]\n\n" + values["txtMessage"];
                MailEngine.SendContactUsMessage(values["txtSubject"], strBody);
                return(PartialView("../Home/_ParContactMessagePost"));
            }
            else
            {
                return(PartialView("../Home/_ParContactMessageWrongCaptcha"));
            }
        }
コード例 #5
0
        public int InsertNewMail(string strSubject, string strBody, string strToEmail, string strCcEmail = "", string strBccEmail = "")
        {
            MailEngine smObj = new MailEngine();

            smObj.Subject = strSubject;
            smObj.Body    = strBody;
            smObj.ToEmail = strToEmail;
            if (!string.IsNullOrWhiteSpace(strCcEmail))
            {
                smObj.CcEmail = strCcEmail;
            }
            if (!string.IsNullOrWhiteSpace(strBccEmail))
            {
                smObj.BccEmail = strBccEmail;
            }
            smObj.IsSent = false;
            _sendMailRepository.Save(smObj);
            return(_unitOfWork.Submit());
        }
コード例 #6
0
 private void SendEmailBatches(List <EmailBatch> batches, IFile filesys)
 {
     try
     {
         //--------------------------------------------------------------------------------------
         // Kick off a Thread to send emails out to all electronic users
         //--------------------------------------------------------------------------------------
         Log.Me.Info("About to kick off the Emailing Thread");
         filesys.ChangeDirectory(Config.Get("UploadDirectory"));
         MailEngine engine = new MailEngine();
         engine.SendGridKey = EmailConfig.Me.SendGridKey;
         engine.FileSys     = filesys;
         string sepchar = Path.DirectorySeparatorChar.ToString();
         engine.LoadTemplates(Config.ContentRoot + sepchar + "Config" + sepchar, "EmailTemplates.txt");
         engine.Start(batches);
         Log.Me.Info("Email Thread started!");
     }
     catch (Exception ex)
     {
         Log.Me.Error("EXCEPTION - " + ex.Message);
     }
 }
コード例 #7
0
        public ActionResult Contact(SupportInfo supportinfo)
        {
            bool   SupportFileExist = false;
            string attachfilepath   = "";
            string fPath            = "";

            if (Request.Files.Count > 0)
            {
                foreach (string file in Request.Files)
                {
                    if (file.ToLower() == "supportfilepath")
                    {
                        HttpPostedFileBase hpf = Request.Files[file];
                        if (hpf.FileName != "")
                        {
                            string extension = System.IO.Path.GetExtension(hpf.FileName);
                            string fname     = "";
                            do
                            {
                                fname = Guid.NewGuid().ToString();
                            } while (!Common.IsValidFileName(Guid.NewGuid().ToString(), true));

                            string path1 = string.Format("{0}/{1}", Server.MapPath("~/Content/Uploads/Contents/Support"), fname + extension);
                            hpf.SaveAs(path1);
                            attachfilepath   = path1;
                            fPath            = "/Content/Uploads/Contents/Support/" + fname + extension;
                            SupportFileExist = true;
                        }
                    }
                }
            }

            // save the SupportInfo object in database.
            SupportInfo ObjSupport = new SupportInfo(); // create object of SupportInfo table to save the record

            ObjSupport.Summary     = supportinfo.Summary;
            ObjSupport.Description = supportinfo.Description;
            if (SupportFileExist == true)
            {
                ObjSupport.FilePath = fPath;
            }
            ObjSupport.UserID      = Convert.ToInt64(Session["UserID"]);
            ObjSupport.SupportDate = DateTime.Now;
            db.SupportInfoes.Add(ObjSupport);
            db.SaveChanges(); // save data in SupportInfo table in database

            string useremail = "";
            long   uid       = Convert.ToInt64(Session["UserID"]);
            var    objuser   = db.UserProfiles.Where(usr => usr.UserId == uid).FirstOrDefault();

            if (objuser != null)
            {
                useremail = objuser.EmailAddress;
            }
            var objInstance = (from o in db.InstanceInfoes
                               where o.InstanceID == 1
                               select new { o.InstanceTitle, o.HostEmail, o.URL, o.SmtpIPv4 }).FirstOrDefault();

            if (objInstance != null && useremail != "")
            {
                string fromEmail = useremail;

                string subject = supportinfo.Summary;

                string body = "<div style='font-family: Arial; font-size: 10pt'>Date sumbitted: " + String.Format("{0:d/M/yyyy}", DateTime.Now) + "<br />Subject: " + supportinfo.Summary + "<br /> Detail: " + supportinfo.Description + "</div>";

                //body = body.Replace("{InstanceTitle}", objInstance.InstanceTitle).Replace("{InstanceURL}", objInstance.URL).Replace("{FirstName}", HttpUtility.HtmlEncode(objUser.FirstName)).Replace("{UserName}", HttpUtility.HtmlEncode(objUser.EmailAddress)).Replace("{Password}", Password).Replace("{Password}", Password); //edit it
                try
                {
                    if (SupportFileExist == true)
                    {
                        MailEngine.SendWithAttachment(fromEmail, objInstance.HostEmail, subject, body, objInstance.SmtpIPv4, attachfilepath);
                    }
                    else
                    {
                        MailEngine.Send(fromEmail, objInstance.HostEmail, subject, body, objInstance.SmtpIPv4);
                    }

                    //MailEngine oLog = new MailEngine();
                    //oLog.LogEmail(fromEmail, objEmail.ID, objUser.UserId);
                    //db.SaveChanges();
                }
                catch (Exception ex)
                {
                }
            }
            //string urlref = Request.UrlReferrer.AbsolutePath;
            //if (urlref.Contains("/") == true)
            //{
            //    string cont = urlref.Substring(urlref.LastIndexOf("/") + 1);
            //    if (cont.ToLower() == "edituserprofile")
            //        return RedirectToAction(cont, "User");
            //    else
            //        return RedirectToAction("Index", cont);
            //}
            return(RedirectToAction("Index", "User"));
        }
コード例 #8
0
 public ComposeEmail(UserAccount ua)
 {
     InitializeComponent();
     _userAccount = ua;
     _mailEngine  = new MailEngine();
 }
コード例 #9
0
        static void Main(string[] args)
        {
            Config.Setup("appsettings.json", Directory.GetCurrentDirectory(), null, "MistwarePostmanTest");

            string connection = Config.Get("AzureConnectionString");
            string container  = Config.Get("AzureContainer");
            string logs       = Config.Get("Logs");
            IFile  filesys    = FileBootstrap.SetupFileSys(connection, container, null, logs);

            Log.Me.LogFile = "MistwarePostmanTest.log";

            EmailBatch batch = new EmailBatch();

            batch.Postmaster = new MailAddress("noreply@" + Config.Get("TestDomain"), "ACME Postmaster");
            batch.From       = new MailAddress(Config.Get("TestEmail"), Config.Get("TestPerson"));
            batch.Name       = "Test Batch";
            batch.Recipients = new List <EmailRecipient>();

            EmailRecipient r1 = new EmailRecipient();

            r1.To              = new MailAddress(Config.Get("TestEmail"), Config.Get("TestPerson"));
            r1.DeliveryType    = "Summary";
            r1.Attachment      = null;
            r1.MailMergeFields = new Dictionary <string, string>();
            r1.MailMergeFields.Add("FromName", "Fred Bloggs");
            r1.MailMergeFields.Add("FromEmail", "*****@*****.**");
            r1.MailMergeFields.Add("ISBN", "9780141198354");
            r1.MailMergeFields.Add("Title", "Bleak House");
            r1.MailMergeFields.Add("Authors", "Charles Dickens");
            r1.MailMergeFields.Add("Summary", "A satirical story about the British judiciary system. \nEsther Summerson is a lonely girl who was raised by her aunt and is taken in by John Jarndyce, a rich philanthropist. Parts of the story are told from her point of view.");
            r1.MailMergeFields.Add("Link", "https://en.wikipedia.org/wiki/Bleak_House");
            batch.Recipients.Add(r1);

            EmailRecipient r2 = new EmailRecipient();

            r2.To              = new MailAddress(Config.Get("TestEmail"), Config.Get("TestPerson"));
            r2.DeliveryType    = "Full";
            r2.Attachment      = "BleakHouse.pdf";
            r2.MailMergeFields = new Dictionary <string, string>();
            r2.MailMergeFields.Add("FromName", "Fred Bloggs");
            r2.MailMergeFields.Add("FromEmail", "*****@*****.**");
            r2.MailMergeFields.Add("ISBN", "9780141198354");
            r2.MailMergeFields.Add("Title", "Bleak House");
            r2.MailMergeFields.Add("Authors", "Charles Dickens");
            batch.Recipients.Add(r2);

            List <EmailBatch> batches = new List <EmailBatch>();

            batches.Add(batch);

            Log.Me.Info("About to kick off the Emailing Thread");
            MailEngine engine = new MailEngine();

            engine.SendGridKey = Config.Get("SendGridKey");
            engine.FileSys     = filesys;
            engine.LoadTemplates(Directory.GetCurrentDirectory() + "/", "EmailTemplates.txt");
            filesys.ChangeDirectory(Config.Get("UploadDirectory"));
            filesys.FileUpload(Directory.GetCurrentDirectory() + "/" + "BleakHouse.pdf");
            engine.Start(batches);

            Thread.Sleep(10000); // Wait 10 secs, so thread will finish before we kill the app.
            filesys.FileDelete("BleakHouse.pdf");
        }