コード例 #1
0
        public void Add(String firstname, String lastname, String email)
        {
            CmsInviteDao dao = new CmsInviteDao();
            CmsInvite invite = dao.FindByEmail(email);
            if (invite != null)
                throw new ArgumentException("This email address has already been registered.");

            invite = new CmsInvite();
            invite.Guid = System.Guid.NewGuid().ToString();
            invite.Firstname = firstname;
            invite.Lastname = lastname;
            invite.Email = email;
            invite.Created = UtcDateTime.Now;
            invite.Issued = DateTime.MaxValue;
            invite.Responded = DateTime.MaxValue;

            using (Transaction tx = new Transaction())
            {
                dao.Save<CmsInvite>(invite);
                tx.Commit();
            }

            SendEmail(GooeyConfigManager.InviteEmailTemplate, "GooeyCMS Invite Request", invite);
        }
コード例 #2
0
        private void SendEmail(string template, String subject, CmsInvite invite)
        {
            template = template.Replace("{firstname}", invite.Firstname);
            template = template.Replace("{lastname}", invite.Lastname);
            template = template.Replace("{email}", invite.Email);
            template = template.Replace("{token}", invite.Token);

            EmailClient client = EmailClient.GetDefaultClient();
            client.ToAddress = invite.Email;
            client.FromAddress = "*****@*****.**";
            client.IsHtmlContent = false;
            client.Send(subject, template);
        }