Exemplo n.º 1
0
        public async Task <ActionResult> Contact(EmailFormObjects model)
        {
            if (ModelState.IsValid)
            {
                var body =
                    "<p>Hello,</p>"
                    + "<p>Can you please send the following item.</p>"
                    + "<h2>{2}</h2>"
                    + "<p>Additional comments:</p>"
                    + "<p>{3}</p>"
                    + "<p>Thank you,</p>"
                    + "<p>{0}</p>"
                    + "<p>{1}</p>";


                var message = new MailMessage();
                message.To.Add(new MailAddress(model.EmailForm.VendorEmail));   // replace with valid value
                message.From       = new MailAddress("*****@*****.**"); // replace with valid value
                message.Subject    = "Sample Requested";
                message.Body       = string.Format(body, model.EmailForm.FromName, model.EmailForm.FromEmail, model.EmailForm.ProductName, model.EmailForm.Message);
                message.IsBodyHtml = true;

                using (var smtp = new SmtpClient())
                {
                    var credential = new NetworkCredential
                    {
                        UserName = "******",
                        Password = "******"  //REMOVE BEFORE SENDING TO GIT!!!!
                    };
                    smtp.Credentials = credential;
                    smtp.Host        = "smtp-mail.outlook.com";
                    smtp.Port        = 587;
                    smtp.EnableSsl   = true;
                    await smtp.SendMailAsync(message);

                    return(RedirectToAction("Sent"));
                }
            }
            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult Contact()
        {
            try
            {
                var accessToken = Session["AccessToken"].ToString();
                var apiVersion  = Session["ApiVersion"].ToString();
                var internalURI = Session["InstanceUrl"].ToString();

                var client = new ForceClient(internalURI, accessToken, apiVersion);

                EmailFormObjects model = new EmailFormObjects();

                model.VendorInfo       = client.QueryAsync <Vendor>("SELECT Name, Title, Email FROM Contact WHERE Title ='Account Executive'").Result.Records;
                model.InventoryManager = client.QueryAsync <InventoryManager>("SELECT Id, Name, CostPrice__c, OwnedPrice__c, RetailCost__c, CurrentInventory__c, InventoryOnOrder__c, SampleInHouse__c, ProductPicture__c FROM Inventory__c Where SampleInHouse__c = False").Result.Records;

                return(View(model));
            }
            catch (Exception e)
            {
                return(RedirectToAction("Index", "InventoryManager"));
            }
        }