public async Task <IActionResult> Contact(ContactForm contact)
        {
            if (ModelState.IsValid)
            {
                string autoMsg = $"<strong>This message was sent via disneycafe.online and from the email address {contact.EmailAddress}</strong><br>" + contact.Body;
                await SendGridEmailHelper.SendEmailToUser(_config, "INSERT COPERATE EMAIL", contact.Subject, autoMsg);

                TempData["WasSuccessful"] = "Your email was sent to DisneyCafe successfully";
                return(RedirectToAction("Index"));
            }

            return(View(contact));
        }
Exemple #2
0
        public Task SendOwnershipInvitation(string emailAddressOfInvitee, UnconfirmedSubmissionOwner unconfirmedSubmissionOwner, string urlAuthority, Func <string, string> htmlEncode)
        {
            using (var db = new WebGalleryDbContext())
            {
                var submission = (from s in db.Submissions
                                  where s.SubmissionID == unconfirmedSubmissionOwner.SubmissionID
                                  select s).FirstOrDefault();

                if (submission == null)
                {
                    return(Task.FromResult(0));
                }

                // html encode some strings
                submission.Nickname = htmlEncode(submission.Nickname);
                submission.Version  = htmlEncode(submission.Version);
                unconfirmedSubmissionOwner.FirstName = htmlEncode(unconfirmedSubmissionOwner.FirstName);
                unconfirmedSubmissionOwner.LastName  = htmlEncode(unconfirmedSubmissionOwner.LastName);
                var invitationGuid = htmlEncode(unconfirmedSubmissionOwner.RequestID.ToString());

                // build the body of the email
                var bodyBuilder = new StringBuilder();
                bodyBuilder.Append($"<p>{unconfirmedSubmissionOwner.FirstName} {unconfirmedSubmissionOwner.LastName}:</p>");
                bodyBuilder.Append($"<p>You have been invited to take co-ownership of an application intended for inclusion in Microsoft's <a href='https://{urlAuthority}' title='Web App Gallery'>Web App Gallery</a>.</p>");
                bodyBuilder.Append("<p>");
                bodyBuilder.Append($"The ID of the application is {submission.Nickname}.<br />");
                bodyBuilder.Append($"The version is {submission.Version}.");
                bodyBuilder.Append("</p>");
                bodyBuilder.Append("<p>");
                bodyBuilder.Append($"To accept this invitation please visit <a href='https://{urlAuthority}/ownership/invitations/{invitationGuid}' title='go here to accept this invitation'>this Web page</a> and follow these steps:");
                bodyBuilder.Append("</p>");
                bodyBuilder.Append("<ol>");
                bodyBuilder.Append("<li>Log into Live ID. If you do not yet have a Live ID account you will be able to create one from the log-in page.</li>");
                bodyBuilder.Append("<li>Provide us with your contact information (unless you have done so in the past).</li>");
                bodyBuilder.Append("<li>Click the appropriate button to accept or decline this invitation.</li>");
                bodyBuilder.Append("</ol>");
                bodyBuilder.Append("<p>");
                bodyBuilder.Append("Best regards,<br />");
                bodyBuilder.Append("Web Application Gallery Team");
                bodyBuilder.Append("</p>");

                var subject = "You are invited to be a co-owner of an Web App Gallery application";
                var from    = GetFromMailAddress();

                SendGridEmailHelper.SendAsync(subject, bodyBuilder.ToString(), from.Address, from.DisplayName, emailAddressOfInvitee);

                return(Task.FromResult(0));
            }
        }
Exemple #3
0
        public Task SendMessageForRebrand(string appId, string newAppId, string operatorEmailAddress)
        {
            // build the body of the email
            var bodyBuilder = new StringBuilder();

            bodyBuilder.Append($"<p>Hi,</p>");
            bodyBuilder.Append($"<p>The app <strong>{appId}</strong> is rebranded with the new Id <strong>{newAppId}</strong> by the operator: <a herf='mailto:{operatorEmailAddress}'>{operatorEmailAddress}</a>.</p>");
            bodyBuilder.Append("<p>");
            bodyBuilder.Append("Best regards,<br />");
            bodyBuilder.Append("Web Application Gallery Team");
            bodyBuilder.Append("</p>");

            var subject = $"The app {appId} is rebranded with the new Id {newAppId}.";
            var from    = GetFromMailAddress();
            var to      = from;
            var cc      = operatorEmailAddress;

            SendGridEmailHelper.SendAsync(subject, bodyBuilder.ToString(), from.Address, from.DisplayName, to.Address, cc);

            return(Task.FromResult(0));
        }
Exemple #4
0
        public Task SendMessageForIssueReported(Issue issue, Func <string, string> htmlEncode)
        {
            // html encode user inputs
            issue.ReporterFirstName = htmlEncode(issue.ReporterFirstName);
            issue.ReporterLastName  = htmlEncode(issue.ReporterLastName);
            issue.IssueDescription  = htmlEncode(issue.IssueDescription);

            var subject = $"Ticket #{issue.IssueID} [{Enum.GetName(typeof(IssueType), issue.IssueType)}]";
            var from    = GetFromMailAddress();

            // set the table's style
            var style = @"
<style>
table tr
{
    margin: 0;
    padding: 0;
}
table tr th,
table tr td
{
    padding: 2px;
    margin: 0;
    border: solid 1px #666666;
    text-align: left;
    font-family: Segoe UI, Verdana, Tahoma, Helvetica, Arial, sans-serif;
    font-size: 12px;
    line-height: 1.2em;
}
</style>
";

            // first, send email to the user who reported the issue
            var messageBodyToUser = new StringBuilder();

            messageBodyToUser.Append($"<p>Hello {issue.ReporterFirstName} {issue.ReporterLastName}</p>");

            // the type of app issue is 2
            if (issue.IssueType == 2)
            {
                messageBodyToUser.Append(style);
                messageBodyToUser.Append("<p>Please share the following details to help resolve the issue.</p>");
                messageBodyToUser.Append("<ol><li>Share the logs in %localappdata%\\microsoft\\Web Platform Installer\\logs folder</li>");
                messageBodyToUser.Append("<li>Screenshots on the error</li>");
                messageBodyToUser.Append("<li>Steps to reproduce the error</li></ol>");
                messageBodyToUser.Append("<p>Here is the expected response time to address your issue.</p>");
                messageBodyToUser.Append("<p><table cellpadding='0' cellspacing='0'>");
                messageBodyToUser.Append("<tr><th>Issue Type</th><th>Response time Service level agreement (SLA)</th></tr>");
                messageBodyToUser.Append("<tr><td>Submission portal issue</td><td>1-3 days</td></tr>");
                messageBodyToUser.Append("<tr><td>Application Issue</td><td>The application owner will get back to you on the issue. </td></tr>");
                messageBodyToUser.Append("</table></p>");
            }
            else
            {
                messageBodyToUser.Append("<p>Thank you for contacting Web App Gallery team! Your request has been received, and is being reviewed by our team.  If you haven’t already, please check out our <a href='http://www.iis.net/learn/develop/windows-web-application-gallery'>documentation</a> or our <a href='http://www.iis.net/learn/develop/windows-web-application-gallery/frequently-asked-questions'>FAQ</a> where you can find answers to the most common questions.</p>");
                messageBodyToUser.Append("<p>Please expect a response from us in 3-5 business days</p>");
            }
            messageBodyToUser.Append("<p>Thanks</p>");
            messageBodyToUser.Append("<p>App Gallery Team</p>");

            SendGridEmailHelper.SendAsync(subject, messageBodyToUser.ToString(), from.Address, from.DisplayName, issue.ReporterEmail);

            // second, send email to Microsoft and/or the app owners
            var messageBodyToMicrosoftOrOwners = new StringBuilder();

            messageBodyToMicrosoftOrOwners.Append("<p>Hello</p>");
            messageBodyToMicrosoftOrOwners.Append($"<p>An issue was reported by <a href='mailto:{issue.ReporterEmail}'>{issue.ReporterFirstName} {issue.ReporterLastName}</a>.</p>");
            messageBodyToMicrosoftOrOwners.Append("<p><table cellpadding='0' cellspacing='0'>");
            var appIdStatement = string.IsNullOrWhiteSpace(issue.AppId) ? string.Empty : $" for the app: {issue.AppId}";

            messageBodyToMicrosoftOrOwners.Append($"<tr><th>Issue Category</th><td>{Enum.GetName(typeof(IssueType), issue.IssueType)}{appIdStatement}</td></tr>");
            messageBodyToMicrosoftOrOwners.Append($"<tr><th>Issue Details</th><td>{issue.IssueDescription}</td></tr>");
            messageBodyToMicrosoftOrOwners.Append("</table></p>");
            messageBodyToMicrosoftOrOwners.Append("<p>Thanks</p>");
            messageBodyToMicrosoftOrOwners.Append("<p>App Gallery Team</p>");

            // get the email addresses of the owners of the app in this issue
            var emailAddressesOfOwners = string.Empty;

            using (var db = new WebGalleryDbContext())
            {
                var addresses = (from s in db.Submissions
                                 join o in db.SubmissionOwners on s.SubmissionID equals o.SubmissionID
                                 join c in db.Submitters on o.SubmitterID equals c.SubmitterID // If App Issue , send the above email to appgal team and application owner email in submitters table .
                                 where s.Nickname == issue.AppId
                                 select c.MicrosoftAccount).AsEnumerable();

                emailAddressesOfOwners = string.Join(",", addresses);
            }

            if (string.IsNullOrWhiteSpace(emailAddressesOfOwners))
            {
                // if found no email addresses of owners, then send to only Microsoft
                var to = from.Address;
                SendGridEmailHelper.SendAsync(subject, style + messageBodyToMicrosoftOrOwners.ToString(), from.Address, from.DisplayName, to);
            }
            else
            {
                // or send to the owners and cc to Microsoft
                var cc = from.Address;
                SendGridEmailHelper.SendAsync(subject, style + messageBodyToMicrosoftOrOwners.ToString(), from.Address, from.DisplayName, emailAddressesOfOwners, cc);
            }

            return(Task.FromResult(0));
        }
Exemple #5
0
        public void SendMessageForSubmission(Submitter submitter, Submission submission, string action, string urlAuthority, Func <string, string> htmlEncode)
        {
            if (submitter == null || submission == null)
            {
                return;
            }

            using (var db = new WebGalleryDbContext())
            {
                var contactInfo = (from c in db.SubmittersContactDetails
                                   where c.SubmitterID == submitter.SubmitterID
                                   select c).FirstOrDefault();
                var metadata = (from m in db.SubmissionLocalizedMetaDatas
                                where m.SubmissionID == submission.SubmissionID
                                select m).ToList();
                var packages = (from p in db.Packages
                                where p.SubmissionID == submission.SubmissionID
                                select p).ToList();
                var frameworkName = (from f in db.FrameworksAndRuntimes
                                     where f.FrameworkOrRuntimeID == submission.FrameworkOrRuntimeID
                                     select f.Name).FirstOrDefault();
                var categoryName1 = (from c in db.ProductOrAppCategories
                                     where c.CategoryID.ToString() == submission.CategoryID1
                                     select c.Name).FirstOrDefault();
                var categoryName2 = (from c in db.ProductOrAppCategories
                                     where c.CategoryID.ToString() == submission.CategoryID2
                                     select c.Name).FirstOrDefault();
                var owners = (from o in db.SubmissionOwners
                              join d in db.SubmittersContactDetails on o.SubmitterID equals d.SubmitterID
                              where o.SubmissionID == submission.SubmissionID
                              select d).ToList();

                // html encode some fields
                submission.Version          = htmlEncode(submission.Version);
                submission.SubmittingEntity = htmlEncode(submission.SubmittingEntity);
                submission.AdditionalInfo   = htmlEncode(submission.AdditionalInfo);
                foreach (var m in metadata)
                {
                    m.Name             = htmlEncode(m.Name);
                    m.Description      = htmlEncode(m.Description);
                    m.BriefDescription = htmlEncode(m.BriefDescription);
                }
                foreach (var p in packages)
                {
                    p.StartPage = htmlEncode(p.StartPage);
                    p.SHA1Hash  = htmlEncode(p.SHA1Hash);
                }

                // build subject and body
                var subject = BuildSubject(submission, action);
                var body    = BuildBody(submitter, contactInfo, submission, categoryName1, categoryName2, frameworkName, metadata, packages, action, urlAuthority);
                body += "Submission:<br/>";

                // create a new anonymous object for serialization
                // to avoid the error "The ObjectContext instance has been disposed ..."
                var submissionJson = new
                {
                    SubmissionID        = submission.SubmissionID,
                    Nickname            = submission.Nickname,
                    Version             = submission.Version,
                    SubmittingEntity    = submission.SubmittingEntity,
                    SubmittingEntityURL = submission.SubmittingEntityURL,
                    AppURL                  = submission.AppURL,
                    SupportURL              = submission.SupportURL,
                    ReleaseDate             = submission.ReleaseDate,
                    ProfessionalServicesURL = submission.ProfessionalServicesURL,
                    CommercialProductURL    = submission.CommercialProductURL,
                    CategoryID1             = submission.CategoryID1,
                    CategoryID2             = submission.CategoryID2,

                    LogoUrl        = submission.LogoUrl,
                    ScreenshotUrl1 = submission.ScreenshotUrl1,
                    ScreenshotUrl2 = submission.ScreenshotUrl2,
                    ScreenshotUrl3 = submission.ScreenshotUrl3,
                    ScreenshotUrl4 = submission.ScreenshotUrl4,
                    ScreenshotUrl5 = submission.ScreenshotUrl5,
                    ScreenshotUrl6 = submission.ScreenshotUrl6,

                    FrameworkOrRuntimeID  = submission.FrameworkOrRuntimeID,
                    DatabaseServerIDs     = submission.DatabaseServerIDs,
                    WebServerExtensionIDs = submission.WebServerExtensionIDs,

                    AgreedToTerms  = submission.AgreedToTerms,
                    AdditionalInfo = submission.AdditionalInfo,

                    Created = submission.Created,
                    Updated = submission.Updated,
                };

                body += JsonConvert.SerializeObject(submissionJson, Formatting.Indented).Replace(" ", "&nbsp").Replace("\r\n", "<br/>");
                body += "<hr/><br/><br/>Submission Metadata:<br/>";
                body += JsonConvert.SerializeObject(metadata, Formatting.Indented).Replace(" ", "&nbsp").Replace("\r\n", "<br/>");

                // get the from email address
                var from = GetFromMailAddress();

                // First send email internally (to folks at MS).
                var to = from.Address;
                SendGridEmailHelper.SendAsync(subject, BuildHtmlStyles() + body, from.Address, from.DisplayName, to);

                // Second, send email externally (to the app owners). Here, we don't include the XML.
                foreach (var owner in owners)
                {
                    var note = string.Empty;
                    switch (action)
                    {
                    case "VERIFIED": note = BuildSubmissionNote(htmlEncode(owner.FullName), from.Address, submission.Nickname, submission.Version, urlAuthority); break;

                    case "PUBLISHED": note = BuildPublishNote(htmlEncode(owner.FullName), submission.Nickname, submission.Version, urlAuthority); break;

                    default: break;
                    }
                    to   = owner.EMail;
                    body = note + BuildBody(submitter, contactInfo, submission, categoryName1, categoryName2, frameworkName, metadata, packages, action, urlAuthority);
                    SendGridEmailHelper.SendAsync(subject, BuildHtmlStyles() + body, from.Address, from.DisplayName, to);
                }
            }
        }