/// <summary>
 /// Create a new Card object.
 /// </summary>
 /// <param name="cardId">Initial value of the CardId property.</param>
 /// <param name="cardStyleId">Initial value of the CardStyleId property.</param>
 /// <param name="senderName">Initial value of the SenderName property.</param>
 /// <param name="senderEmail">Initial value of the SenderEmail property.</param>
 /// <param name="recipientName">Initial value of the RecipientName property.</param>
 /// <param name="recipientEmail">Initial value of the RecipientEmail property.</param>
 /// <param name="greeting">Initial value of the Greeting property.</param>
 /// <param name="message">Initial value of the Message property.</param>
 /// <param name="isSent">Initial value of the IsSent property.</param>
 public static Card CreateCard(global::System.Int32 cardId, global::System.Int32 cardStyleId, global::System.String senderName, global::System.String senderEmail, global::System.String recipientName, global::System.String recipientEmail, global::System.String greeting, global::System.String message, global::System.Boolean isSent)
 {
     Card card = new Card();
     card.CardId = cardId;
     card.CardStyleId = cardStyleId;
     card.SenderName = senderName;
     card.SenderEmail = senderEmail;
     card.RecipientName = recipientName;
     card.RecipientEmail = recipientEmail;
     card.Greeting = greeting;
     card.Message = message;
     card.IsSent = isSent;
     return card;
 }
Exemple #2
0
        private void SendMail(Card card)
        {
            string mailState = System.Configuration.ConfigurationSettings.AppSettings["mailState"];

            try
            {
                logger.Log("Entering Send Mail--" + card.CardId);

                PgpEntities svc = new PgpEntities();

                var query = from m in svc.MailSettings
                            where m.Active == true
                            select m;
                MailSetting settings = query.First();

                MailMessage msg = new MailMessage();
                msg.From = new MailAddress(settings.EmailAccountName);
                msg.To.Add(card.RecipientEmail);
                msg.CC.Add(card.SenderEmail);

                msg.Subject = settings.Subject;

                //TODO: Check URL for paint georgia pink
                string body = settings.Body + "\n" + settings.PickupURL + "?CardId=" + card.CardId;
                msg.Body = body;

                //SmtpClient mailer = new SmtpClient(settings.SmtpServer,587);
                SmtpClient mailer = new SmtpClient(settings.SmtpServer,settings.Port);
                mailer.UseDefaultCredentials = false;

                mailer.EnableSsl = false;
                mailer.ServicePoint.MaxIdleTime = 1;

                //mailer.Credentials = new System.Net.NetworkCredential
                //    (settings.EmailAccountName, settings.EmailAccountPassword);

                logger.Log(settings.EmailAccountName + " | " + settings.EmailAccountPassword + " | " + settings.SmtpServer);
                logger.Log("SSL: " + mailer.EnableSsl.ToString() + "HOST:" + mailer.Host + "PORT:" + mailer.Port.ToString() + "DEFAULT-CREDS: " +  mailer.UseDefaultCredentials.ToString());

                if (mailState == "on")
                {
                    mailer.Send(msg);
                    logger.Log("Card #" + card.CardId + " -- mail sent!");
                }
                else
                    logger.Log("Mail setting is off.. switch config to 'on' to enable mail sending");

            }
            catch (Exception ex)
            {
                string exMsg = null;
                if (ex.InnerException != null)
                    exMsg = ex.InnerException.Message;
                else
                    exMsg = ex.Message;

                logger.Log(ex.Source, exMsg, ex.Data.ToString(), ex.StackTrace, ex.TargetSite.Name, PaintGeorgiaPink.Logger.ErrorLevels.ERROR,
                    "CARD NO: " + card.CardId + "-- unable to send mail");

            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Cards EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCards(Card card)
 {
     base.AddObject("Cards", card);
 }